Skip to content

Commit d3a54ce

Browse files
bcallaghan-etBen Callaghan
authored andcommitted
fix(core): include serve target only for applications (#30)
Do not include serve target for libraries as they cannot be run directly. Fixes #28 Co-authored-by: Ben Callaghan <bcallaghan@selectbankcard.com>
1 parent 0141ed3 commit d3a54ce

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/core/src/generators/utils/generate-project.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ describe('nx-dotnet project generator', () => {
4242
expect(config).toBeDefined();
4343
});
4444

45+
it('should not include serve target for libraries', async () => {
46+
await GenerateProject(appTree, options, dotnetClient, 'library');
47+
const config = readProjectConfiguration(appTree, 'test');
48+
expect(config.targets.serve).not.toBeDefined();
49+
})
50+
4551
it('should tag generated projects', async () => {
4652
await GenerateProject(appTree, options, dotnetClient, 'library');
4753
const config = readProjectConfiguration(appTree, 'test');
@@ -66,6 +72,12 @@ describe('nx-dotnet project generator', () => {
6672
expect(absoluteDistPath).toEqual(expectedDistPath);
6773
});
6874

75+
it('should include serve target for applications', async () => {
76+
await GenerateProject(appTree, options, dotnetClient, 'application');
77+
const config = readProjectConfiguration(appTree, 'test');
78+
expect(config.targets.serve).toBeDefined();
79+
})
80+
6981
/**
7082
* This test requires a live dotnet client.
7183
*/

packages/core/src/generators/utils/generate-project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export async function GenerateProject(
188188
sourceRoot: `${normalizedOptions.projectRoot}`,
189189
targets: {
190190
build: GetBuildExecutorConfiguration(normalizedOptions.projectRoot),
191-
serve: GetServeExecutorConfig(),
191+
...(projectType === 'application' ? { serve: GetServeExecutorConfig() } : {}),
192192
},
193193
tags: normalizedOptions.parsedTags,
194194
};

0 commit comments

Comments
 (0)