From 01931612d3f6e4150f825782134008c8a6d6c42b Mon Sep 17 00:00:00 2001 From: Carlos Emiliano Castro Trejo <102700317+ccastrotrejo@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:57:20 -0700 Subject: [PATCH] fix(vscode): Keep host.json when converting to NuGet based project (#4534) Update host.json when converting to NuGet based project --- .../workflows/switchToDotnetProject.ts | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/apps/vs-code-designer/src/app/commands/workflows/switchToDotnetProject.ts b/apps/vs-code-designer/src/app/commands/workflows/switchToDotnetProject.ts index 843ee8a082c..1d6eead66e7 100644 --- a/apps/vs-code-designer/src/app/commands/workflows/switchToDotnetProject.ts +++ b/apps/vs-code-designer/src/app/commands/workflows/switchToDotnetProject.ts @@ -2,7 +2,14 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { connectionsFileName, funcIgnoreFileName, funcVersionSetting, hostFileName, localSettingsFileName } from '../../../constants'; +import { + connectionsFileName, + funcIgnoreFileName, + funcVersionSetting, + hostFileName, + localSettingsFileName, + workflowFileName, +} from '../../../constants'; import { localize } from '../../../localize'; import { initProjectForVSCode } from '../../commands/initProjectForVSCode/initProjectForVSCode'; import { DotnetTemplateProvider } from '../../templates/dotnet/DotnetTemplateProvider'; @@ -191,7 +198,7 @@ async function updateBuildFile(context: IActionContext, target: vscode.Uri, dotn } async function deleteBundleProjectFiles(target: vscode.Uri): Promise { - const filesTobeDeleted: string[] = [hostFileName, funcIgnoreFileName]; + const filesTobeDeleted: string[] = [funcIgnoreFileName]; for (const fileName of filesTobeDeleted) { if (await fse.pathExists(path.join(target.fsPath, fileName))) { await deleteFile(path.join(target.fsPath, fileName)); @@ -204,7 +211,7 @@ async function deleteFile(file: string): Promise { } async function renameBundleProjectFiles(target: vscode.Uri): Promise { - const filesToBeRenamed: string[] = [localSettingsFileName]; + const filesToBeRenamed: string[] = [hostFileName, localSettingsFileName]; for (const fileName of filesToBeRenamed) { if (await fse.pathExists(path.join(target.fsPath, fileName))) { await renameFile(path.join(target.fsPath, fileName), path.join(target.fsPath, fileName + '-copy')); @@ -217,7 +224,7 @@ async function renameFile(fileName: string, newFileName: string): Promise } async function copyBundleProjectFiles(target: vscode.Uri): Promise { - const filesToBeCopied: string[] = [localSettingsFileName]; + const filesToBeCopied: string[] = [hostFileName, localSettingsFileName]; for (const fileName of filesToBeCopied) { if ( (await fse.pathExists(path.join(target.fsPath, fileName))) && @@ -229,8 +236,8 @@ async function copyBundleProjectFiles(target: vscode.Uri): Promise { } } -async function getArtifactNamesFromProject(target: vscode.Uri): Promise<{ [key: string]: string[] }> { - const artifactDict: { [key: string]: string[] } = { +async function getArtifactNamesFromProject(target: vscode.Uri): Promise> { + const artifactDict: Record = { workflows: [], connections: [], artifacts: [], @@ -256,7 +263,7 @@ async function getArtifactNamesFromProject(target: vscode.Uri): Promise<{ [key: const filePath: string = path.join(target.fsPath, file); if (await (await fse.stat(filePath)).isDirectory()) { const workflowFiles: string[] = await fse.readdir(filePath); - if (workflowFiles.length == 1 && workflowFiles[0] == 'workflow.json') { + if (workflowFiles.length == 1 && workflowFiles[0] == workflowFileName) { artifactDict['workflows'].push(file); } }