Skip to content

Commit 12df7e0

Browse files
Merge pull request #969 from OfficeDev/user/archiesaxena/fixStopDebugError
User/archiesaxena/fix stop debug error
2 parents b095a08 + 74b86d9 commit 12df7e0

3 files changed

Lines changed: 23 additions & 15 deletions

File tree

packages/office-addin-dev-settings/src/dev-settings-mac.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ export async function unregisterAddIn(addinId: string, manifestPath: string): Pr
119119

120120
if (registeredFileName === manifestFileName || registeredFileName.startsWith(addinId)) {
121121
if (!registeredFileName.endsWith(".xml")) {
122-
uninstallWithTeams(registeredFileName.substring(registeredFileName.indexOf(".") + 1));
122+
// Try manifest id first, fall back to titleId from filename
123+
const titleIdFromFilename = registeredFileName.substring(registeredFileName.indexOf(".") + 1);
124+
const idToUninstall = addinId || titleIdFromFilename;
125+
uninstallWithTeams(idToUninstall);
123126
// TODO: Add support for refreshing add-ins in Outlook via registry key
124127
}
125128
fs.unlinkSync(registeredAddIn.manifestPath);
@@ -133,7 +136,10 @@ export async function unregisterAllAddIns(): Promise<void> {
133136
for (const registeredAddIn of registeredAddIns) {
134137
const registeredFileName = path.basename(registeredAddIn.manifestPath);
135138
if (!registeredFileName.endsWith(".xml")) {
136-
uninstallWithTeams(registeredFileName.substring(registeredFileName.indexOf(".") + 1));
139+
// Try manifest id first, fall back to titleId from filename
140+
const titleIdFromFilename = registeredFileName.substring(registeredFileName.indexOf(".") + 1);
141+
const idToUninstall = registeredAddIn.id || titleIdFromFilename;
142+
uninstallWithTeams(idToUninstall);
137143
// TODO: Add support for refreshing add-ins in Outlook via registry key
138144
}
139145
fs.unlinkSync(registeredAddIn.manifestPath);

packages/office-addin-dev-settings/src/dev-settings-windows.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,9 @@ async function unacquire(key: registry.RegistryKey, id: string) {
340340
if (manifest != undefined) {
341341
const key = getDeveloperSettingsRegistryKey(OutlookSideloadManifestPath);
342342
const registration = await registry.getStringValue(key, TitleId);
343-
const uninstallId = registration != undefined ? registration : id;
344-
if (await uninstallWithTeams(uninstallId)) {
343+
// Try manifest id first, fall back to titleId from registry
344+
const uninstallId = id || registration;
345+
if (uninstallId && await uninstallWithTeams(uninstallId)) {
345346
if (registration != undefined) {
346347
registry.deleteValue(key, TitleId);
347348
}

packages/office-addin-dev-settings/src/publish.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,21 @@ export async function uninstallWithTeams(id: string): Promise<boolean> {
5757
return new Promise((resolve, reject) => {
5858
const guidRegex = /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/;
5959
const manifestIdRegex = new RegExp(`^${guidRegex.source}$`);
60-
const titleIdRegex = new RegExp(`^U_${guidRegex.source}$`);
61-
let mode: string = "";
60+
const titleIdRegex = new RegExp(`^.+_(${guidRegex.source})$`);
61+
let uninstallId: string = id;
6262

63-
if (titleIdRegex.test(id)) {
64-
mode = `--mode title-id --title-id ${id}`;
65-
} else if (manifestIdRegex.test(id)) {
66-
mode = `--mode manifest-id --manifest-id ${id}`;
67-
} else {
68-
console.error(`Error: Invalid id "${id}". Add-in is still installed.`);
69-
resolve(false);
70-
return;
63+
if (!manifestIdRegex.test(id)) {
64+
const match = id.match(titleIdRegex);
65+
if (match) {
66+
uninstallId = match[1];
67+
} else {
68+
console.error(`Error: Invalid id "${id}". Add-in is still installed.`);
69+
resolve(false);
70+
return;
71+
}
7172
}
7273

73-
const uninstallCommand = `npx -p @microsoft/m365agentstoolkit-cli atk uninstall ${mode} --interactive false`;
74+
const uninstallCommand = `npx -p @microsoft/m365agentstoolkit-cli atk uninstall --mode manifest-id --manifest-id ${uninstallId} --interactive false`;
7475
console.log(`running: ${uninstallCommand}`);
7576
childProcess.exec(uninstallCommand, (error, stdout, stderr) => {
7677
if (error || stderr.match('"error"')) {

0 commit comments

Comments
 (0)