Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/office-addin-dev-settings/src/dev-settings-mac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ export async function unregisterAddIn(addinId: string, manifestPath: string): Pr

if (registeredFileName === manifestFileName || registeredFileName.startsWith(addinId)) {
if (!registeredFileName.endsWith(".xml")) {
uninstallWithTeams(registeredFileName.substring(registeredFileName.indexOf(".") + 1));
// Try manifest id first, fall back to titleId from filename
const titleIdFromFilename = registeredFileName.substring(registeredFileName.indexOf(".") + 1);
const idToUninstall = addinId || titleIdFromFilename;
uninstallWithTeams(idToUninstall);
// TODO: Add support for refreshing add-ins in Outlook via registry key
}
fs.unlinkSync(registeredAddIn.manifestPath);
Expand All @@ -133,7 +136,10 @@ export async function unregisterAllAddIns(): Promise<void> {
for (const registeredAddIn of registeredAddIns) {
const registeredFileName = path.basename(registeredAddIn.manifestPath);
if (!registeredFileName.endsWith(".xml")) {
uninstallWithTeams(registeredFileName.substring(registeredFileName.indexOf(".") + 1));
// Try manifest id first, fall back to titleId from filename
const titleIdFromFilename = registeredFileName.substring(registeredFileName.indexOf(".") + 1);
const idToUninstall = registeredAddIn.id || titleIdFromFilename;
uninstallWithTeams(idToUninstall);
// TODO: Add support for refreshing add-ins in Outlook via registry key
}
fs.unlinkSync(registeredAddIn.manifestPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,9 @@ async function unacquire(key: registry.RegistryKey, id: string) {
if (manifest != undefined) {
const key = getDeveloperSettingsRegistryKey(OutlookSideloadManifestPath);
const registration = await registry.getStringValue(key, TitleId);
const uninstallId = registration != undefined ? registration : id;
if (await uninstallWithTeams(uninstallId)) {
// Try manifest id first, fall back to titleId from registry
const uninstallId = id || registration;
if (uninstallId && await uninstallWithTeams(uninstallId)) {
if (registration != undefined) {
registry.deleteValue(key, TitleId);
}
Expand Down
23 changes: 12 additions & 11 deletions packages/office-addin-dev-settings/src/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,21 @@ export async function uninstallWithTeams(id: string): Promise<boolean> {
return new Promise((resolve, reject) => {
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}/;
const manifestIdRegex = new RegExp(`^${guidRegex.source}$`);
const titleIdRegex = new RegExp(`^U_${guidRegex.source}$`);
let mode: string = "";
const titleIdRegex = new RegExp(`^.+_(${guidRegex.source})$`);
let uninstallId: string = id;

if (titleIdRegex.test(id)) {
mode = `--mode title-id --title-id ${id}`;
} else if (manifestIdRegex.test(id)) {
mode = `--mode manifest-id --manifest-id ${id}`;
} else {
console.error(`Error: Invalid id "${id}". Add-in is still installed.`);
resolve(false);
return;
if (!manifestIdRegex.test(id)) {
const match = id.match(titleIdRegex);
if (match) {
uninstallId = match[1];
} else {
console.error(`Error: Invalid id "${id}". Add-in is still installed.`);
resolve(false);
return;
}
}

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