From eba0da098c88467191159a05d7302dc5b3867759 Mon Sep 17 00:00:00 2001 From: Eric Jizba Date: Mon, 22 Oct 2018 13:34:24 -0700 Subject: [PATCH] Fix C# project creation logic to handle 'netcoreapp' (#754) Looks like C# project used to default to 'netstandard2.0' and now they default to 'netcoreapp2.1' --- src/commands/createNewProject/CSharpProjectCreator.ts | 2 +- test/createNewProject.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commands/createNewProject/CSharpProjectCreator.ts b/src/commands/createNewProject/CSharpProjectCreator.ts index 3d6515a85..6fc6972a4 100644 --- a/src/commands/createNewProject/CSharpProjectCreator.ts +++ b/src/commands/createNewProject/CSharpProjectCreator.ts @@ -160,7 +160,7 @@ export class CSharpProjectCreator extends ProjectCreatorBase { } else { const targetFramework: string = matches[1]; this.telemetryProperties.cSharpTargetFramework = targetFramework; - if (targetFramework.startsWith('netstandard')) { + if (/net(standard|core)/i.test(targetFramework)) { this._runtime = ProjectRuntime.v2; } else { this._runtime = ProjectRuntime.v1; diff --git a/test/createNewProject.test.ts b/test/createNewProject.test.ts index adfcfe720..fb06e070c 100644 --- a/test/createNewProject.test.ts +++ b/test/createNewProject.test.ts @@ -66,7 +66,7 @@ suite('Create New Project Tests', async function (this: ISuiteCallbackContext): await validateVSCodeProjectFiles(projectPath); const projectName: string = path.basename(projectPath); assert.equal(await fse.pathExists(path.join(projectPath, `${projectName}.csproj`)), true, 'csproj does not exist'); - await validateSetting(projectPath, `${extensionPrefix}.${deploySubpathSetting}`, 'bin/Release/netstandard2.0/publish'); + await validateSetting(projectPath, `${extensionPrefix}.${deploySubpathSetting}`, 'bin/Release/netcoreapp2.1/publish'); }); const bashProject: string = 'BashProject'; @@ -150,7 +150,7 @@ suite('Create New Project Tests', async function (this: ISuiteCallbackContext): const projectPath: string = path.join(testFolderPath, 'createNewProjectApiCSharp'); ext.ui = new TestUserInput([DialogResponses.skipForNow.title]); await vscode.commands.executeCommand('azureFunctions.createNewProject', projectPath, 'C#', '~2', false /* openFolder */, templateId, functionName, { namespace: namespace, Path: iotPath, Connection: connection }); - await validateSetting(projectPath, `${extensionPrefix}.${deploySubpathSetting}`, 'bin/Release/netstandard2.0/publish'); + await validateSetting(projectPath, `${extensionPrefix}.${deploySubpathSetting}`, 'bin/Release/netcoreapp2.1/publish'); }); async function testCreateNewProject(projectPath: string, language: string, previewLanguage: boolean, ...inputs: (string | undefined)[]): Promise {