Add dacpac references to sqlproj with relative path (#14877)

* relative paths written to sqlproj, but can't delete yet

* only keep track of relative path

* remove leading slash

* add test

* use path.relative

* Add error message if dacpac reference is located on a different drive
This commit is contained in:
Kim Santiago
2021-03-30 17:06:04 -07:00
committed by GitHub
parent af4ad1fcb1
commit f4e1f85e0f
5 changed files with 87 additions and 1 deletions

View File

@@ -54,6 +54,27 @@ export class AddDatabaseReferenceDialog {
constructor(private project: Project) {
this.dialog = azdata.window.createModelViewDialog(constants.addDatabaseReferenceDialogName, 'addDatabaseReferencesDialog');
this.addDatabaseReferenceTab = azdata.window.createTab(constants.addDatabaseReferenceDialogName);
this.dialog.registerCloseValidator(async () => {
return this.validate();
});
}
validate(): boolean {
// only support adding dacpacs that are on the same drive as the sqlproj
if (this.currentReferenceType === ReferenceType.dacpac) {
const projectDrive = path.parse(this.project.projectFilePath).root;
const dacpacDrive = path.parse(this.dacpacTextbox!.value!).root;
if (projectDrive !== dacpacDrive) {
this.dialog.message = {
text: constants.dacpacNotOnSameDrive(this.project.projectFilePath),
level: azdata.window.MessageLevel.Error
};
return false;
}
}
return true;
}
public async openDialog(): Promise<void> {