support building msbuild sdk style projects (#17675)

* support building msbuild sdk style projects

* fixes after merge
This commit is contained in:
Kim Santiago
2021-11-17 07:59:43 -10:00
committed by GitHub
parent 9e5a012dcd
commit 6f03cbac97
3 changed files with 21 additions and 4 deletions

View File

@@ -223,7 +223,7 @@ export class ProjectsController {
const options: ShellCommandOptions = { const options: ShellCommandOptions = {
commandTitle: 'Build', commandTitle: 'Build',
workingDirectory: project.projectFolderPath, workingDirectory: project.projectFolderPath,
argument: this.buildHelper.constructBuildArguments(project.projectFilePath, this.buildHelper.extensionBuildDirPath) argument: this.buildHelper.constructBuildArguments(project.projectFilePath, this.buildHelper.extensionBuildDirPath, project.isSdkStyleProject)
}; };
try { try {

View File

@@ -14,7 +14,7 @@ describe('BuildHelper: Build Helper tests', function (): void {
it('Should get correct build arguments', function (): void { it('Should get correct build arguments', function (): void {
// update settings and validate // update settings and validate
const buildHelper = new BuildHelper(); const buildHelper = new BuildHelper();
const resultArg = buildHelper.constructBuildArguments('dummy\\project path\\more space in path', 'dummy\\dll path'); const resultArg = buildHelper.constructBuildArguments('dummy\\project path\\more space in path', 'dummy\\dll path', false);
if (os.platform() === 'win32') { if (os.platform() === 'win32') {
should(resultArg).equal(' build "dummy\\\\project path\\\\more space in path" /p:NetCoreBuild=true /p:NETCoreTargetsPath="dummy\\\\dll path"'); should(resultArg).equal(' build "dummy\\\\project path\\\\more space in path" /p:NetCoreBuild=true /p:NETCoreTargetsPath="dummy\\\\dll path"');
@@ -24,6 +24,19 @@ describe('BuildHelper: Build Helper tests', function (): void {
} }
}); });
it('Should get correct build arguments for sdk style projects', function (): void {
// update settings and validate
const buildHelper = new BuildHelper();
const resultArg = buildHelper.constructBuildArguments('dummy\\project path\\more space in path', 'dummy\\dll path', true);
if (os.platform() === 'win32') {
should(resultArg).equal(' build "dummy\\\\project path\\\\more space in path" /p:NetCoreBuild=true');
}
else {
should(resultArg).equal(' build "dummy/project path/more space in path" /p:NetCoreBuild=true');
}
});
it('Should get correct build folder', async function (): Promise<void> { it('Should get correct build folder', async function (): Promise<void> {
const buildHelper = new BuildHelper(); const buildHelper = new BuildHelper();
await buildHelper.createBuildDirFolder(); await buildHelper.createBuildDirFolder();

View File

@@ -80,10 +80,14 @@ export class BuildHelper {
return this.extensionBuildDir; return this.extensionBuildDir;
} }
public constructBuildArguments(projectPath: string, buildDirPath: string): string { public constructBuildArguments(projectPath: string, buildDirPath: string, isNetCoreSdkStyleProject: boolean): string {
projectPath = utils.getQuotedPath(projectPath); projectPath = utils.getQuotedPath(projectPath);
buildDirPath = utils.getQuotedPath(buildDirPath); buildDirPath = utils.getQuotedPath(buildDirPath);
return ` build ${projectPath} /p:NetCoreBuild=true /p:NETCoreTargetsPath=${buildDirPath}`; if (isNetCoreSdkStyleProject) {
return ` build ${projectPath} /p:NetCoreBuild=true`;
} else {
return ` build ${projectPath} /p:NetCoreBuild=true /p:NETCoreTargetsPath=${buildDirPath}`;
}
} }
} }