Add ability to create publish profile from project context (#23110)

* Ability to add publish profile from project context

* Add/update test + fix Build vs None addition to sqlproj file
This commit is contained in:
Sakshi Sharma
2023-05-15 16:14:07 -07:00
committed by GitHub
parent b56f2ccb60
commit b260edcec3
10 changed files with 64 additions and 6 deletions

View File

@@ -246,6 +246,9 @@ export class ProjectsController {
case ItemType.postDeployScript:
await project.addPostDeploymentScript(relativePath);
break;
case ItemType.publishProfile:
await project.addNoneItem(relativePath);
break;
default: // a normal SQL object script
await project.addSqlObjectScript(relativePath);
break;
@@ -729,7 +732,10 @@ export class ProjectsController {
const itemType = templates.get(itemTypeName);
const absolutePathToParent = path.join(project.projectFolderPath, relativePath);
let itemObjectName = await this.promptForNewObjectName(itemType, project, absolutePathToParent, constants.sqlFileExtension, options?.defaultName);
const isItemTypePublishProfile = itemTypeName === constants.publishProfileFriendlyName || itemTypeName === ItemType.publishProfile;
const fileExtension = isItemTypePublishProfile ? constants.publishProfileExtension : constants.sqlFileExtension;
const defaultName = isItemTypePublishProfile ? `${project.projectFileName}_` : options?.defaultName;
let itemObjectName = await this.promptForNewObjectName(itemType, project, absolutePathToParent, fileExtension, defaultName);
itemObjectName = itemObjectName?.trim();
@@ -737,7 +743,7 @@ export class ProjectsController {
return; // user cancelled
}
const relativeFilePath = path.join(relativePath, itemObjectName + constants.sqlFileExtension);
const relativeFilePath = path.join(relativePath, itemObjectName + fileExtension);
const telemetryProps: Record<string, string> = { itemType: itemType.type };
const telemetryMeasurements: Record<string, number> = {};
@@ -749,7 +755,7 @@ export class ProjectsController {
}
try {
const absolutePath = await this.addFileToProjectFromTemplate(project, itemType, relativeFilePath, new Map([['OBJECT_NAME', itemObjectName]]));
const absolutePath = await this.addFileToProjectFromTemplate(project, itemType, relativeFilePath, new Map([['OBJECT_NAME', itemObjectName], ['PROJECT_NAME', project.projectFileName]]));
TelemetryReporter.createActionEvent(TelemetryViews.ProjectTree, TelemetryActions.addItemFromTree)
.withAdditionalProperties(telemetryProps)