diff --git a/package.json b/package.json index 9d30c27e..3dcf9183 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nx-dotnet", "license": "MIT", - "version": "0.1.5-dev.9", + "version": "0.1.5-dev.10", "scripts": { "nx": "nx", "start": "nx serve", diff --git a/packages/core/package.json b/packages/core/package.json index f44f85a0..32200c4e 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -6,9 +6,9 @@ "private": false, "dependencies": { "chokidar": "^3.5.1", - "@nx-dotnet/dotnet": "0.1.5-dev.9", - "@nx-dotnet/utils": "0.1.5-dev.9", + "@nx-dotnet/dotnet": "0.1.5-dev.10", + "@nx-dotnet/utils": "0.1.5-dev.10", "xmldoc": "^1.1.2" }, - "version": "0.1.5-dev.9" + "version": "0.1.5-dev.10" } \ No newline at end of file diff --git a/packages/core/src/generators/utils/generate-project.ts b/packages/core/src/generators/utils/generate-project.ts index a59d25aa..29d9ffa4 100644 --- a/packages/core/src/generators/utils/generate-project.ts +++ b/packages/core/src/generators/utils/generate-project.ts @@ -1,14 +1,25 @@ import { - addProjectConfiguration, formatFiles, getWorkspaceLayout, names, NxJsonProjectConfiguration, - ProjectConfiguration, ProjectType, Tree + addProjectConfiguration, + formatFiles, + getWorkspaceLayout, + names, + NxJsonProjectConfiguration, + ProjectConfiguration, + ProjectType, + Tree, } from '@nrwl/devkit'; import { DotNetClient, dotnetNewOptions } from '@nx-dotnet/dotnet'; import { findProjectFileInPath, isDryRun } from '@nx-dotnet/utils'; +import { readFileSync, writeFileSync } from 'fs'; +import { XmlDocument, XmlNode, XmlTextNode } from 'xmldoc'; +import { relative, dirname } from 'path'; import { - GetBuildExecutorConfiguration, GetServeExecutorConfig, GetTestExecutorConfig, - NxDotnetProjectGeneratorSchema + GetBuildExecutorConfiguration, + GetServeExecutorConfig, + GetTestExecutorConfig, + NxDotnetProjectGeneratorSchema, } from '../../models'; import initSchematic from '../init/generator'; @@ -71,7 +82,7 @@ async function GenerateTestProject( sourceRoot: `${testRoot}`, targets: { build: GetBuildExecutorConfiguration(testName), - test: GetTestExecutorConfig() + test: GetTestExecutorConfig(), }, tags: schema.parsedTags, }); @@ -98,16 +109,50 @@ async function GenerateTestProject( } dotnetClient.new(schema['test-template'], newParams); - + if (!isDryRun()) { const testCsProj = await findProjectFileInPath(testRoot); + SetOutputPath(host, testProjectName, testCsProj); const baseCsProj = await findProjectFileInPath(schema.projectRoot); + SetOutputPath(host, schema.projectName, baseCsProj); dotnetClient.addProjectReference(testCsProj, baseCsProj); - } + } +} +function SetOutputPath( + host: Tree, + projectName: string, + projectFilePath: string +): void { + const xml: XmlDocument = new XmlDocument( + readFileSync(projectFilePath).toString() + ); + + const textNode: Partial = { + text: `${relative(dirname(projectFilePath), process.cwd())}\\dist\\${projectName}`, + type: 'text' + }; + textNode.toString = () => textNode.text ?? ''; + textNode.toStringWithIndent = () => textNode.text ?? ''; + + const el: Partial = { + name: 'OutputPath', + attr: {}, + type: 'element', + children: [textNode as XmlTextNode], + firstChild: null, + lastChild: null + }; + + el.toStringWithIndent = xml.toStringWithIndent.bind(el); + el.toString = xml.toString.bind(el); + + xml.childNamed('PropertyGroup')?.children.push(el as XmlNode); + + writeFileSync(projectFilePath, xml.toString()); } -export async function GenerateProject ( +export async function GenerateProject( host: Tree, options: NxDotnetProjectGeneratorSchema, dotnetClient: DotNetClient, @@ -119,22 +164,29 @@ export async function GenerateProject ( const normalizedOptions = normalizeOptions(host, options, projectType); - const projectConfiguration: ProjectConfiguration & NxJsonProjectConfiguration = { + const projectConfiguration: ProjectConfiguration & + NxJsonProjectConfiguration = { root: normalizedOptions.projectRoot, projectType: projectType, sourceRoot: `${normalizedOptions.projectRoot}`, targets: { build: GetBuildExecutorConfiguration(normalizedOptions.name), - serve: GetServeExecutorConfig() + serve: GetServeExecutorConfig(), }, tags: normalizedOptions.parsedTags, - } + }; if (options['test-template'] !== 'none') { - projectConfiguration.targets.test = GetTestExecutorConfig(normalizedOptions.projectName + '-test') + projectConfiguration.targets.test = GetTestExecutorConfig( + normalizedOptions.projectName + '-test' + ); } - addProjectConfiguration(host, normalizedOptions.projectName, projectConfiguration); + addProjectConfiguration( + host, + normalizedOptions.projectName, + projectConfiguration + ); const newParams: dotnetNewOptions = [ { @@ -160,7 +212,18 @@ export async function GenerateProject ( dotnetClient.new(normalizedOptions.template, newParams); if (options['test-template'] !== 'none') { - await GenerateTestProject(normalizedOptions, host, dotnetClient, projectType); + await GenerateTestProject( + normalizedOptions, + host, + dotnetClient, + projectType + ); + } else { + SetOutputPath( + host, + normalizedOptions.projectName, + await findProjectFileInPath(normalizedOptions.projectRoot) + ); } await formatFiles(host); diff --git a/packages/dotnet/package.json b/packages/dotnet/package.json index 2e680783..a3171c85 100644 --- a/packages/dotnet/package.json +++ b/packages/dotnet/package.json @@ -3,7 +3,7 @@ "private": false, "main": "src/index.js", "dependencies": { - "@nx-dotnet/utils": "0.1.5-dev.9" + "@nx-dotnet/utils": "0.1.5-dev.10" }, - "version": "0.1.5-dev.9" + "version": "0.1.5-dev.10" } \ No newline at end of file diff --git a/packages/dotnet/src/lib/models/dotnet-test/dotnet-test-flags.ts b/packages/dotnet/src/lib/models/dotnet-test/dotnet-test-flags.ts index 442d6876..a1b7c93f 100644 --- a/packages/dotnet/src/lib/models/dotnet-test/dotnet-test-flags.ts +++ b/packages/dotnet/src/lib/models/dotnet-test/dotnet-test-flags.ts @@ -1,5 +1,22 @@ export type dotnetTestFlags = - | 'test-adapter-path' - | 'blame' + | 'blame-crash-collect-always' + | 'blame-crash-dump-type' | 'blame-crash' - | 'blame-crash-dump-type'; + | 'blame-hang-dump' + | 'blame-hang-timeout' + | 'blame-hang' + | 'blame' + | 'collect' + | 'configuration' + | 'diag' + | 'filter' + | 'framework' + | 'list-tests' + | 'logger' + | 'no-build' + | 'no-restore' + | 'nologo' + | 'results-directory' + | 'settings' + | 'test-adapter-path' + | 'verbosity'; diff --git a/packages/typescript/package.json b/packages/typescript/package.json index 35c95679..800d4f58 100644 --- a/packages/typescript/package.json +++ b/packages/typescript/package.json @@ -3,5 +3,5 @@ "main": "src/index.js", "generators": "./generators.json", "executors": "./executors.json", - "version": "0.1.5-dev.9" + "version": "0.1.5-dev.10" } \ No newline at end of file diff --git a/packages/utils/package.json b/packages/utils/package.json index 6033f68c..7d4c2680 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -7,5 +7,5 @@ "rimraf": "^3.0.2", "xmldoc": "^1.1.2" }, - "version": "0.1.5-dev.9" + "version": "0.1.5-dev.10" } \ No newline at end of file