-
-
Notifications
You must be signed in to change notification settings - Fork 276
/
uninstall.ps1
38 lines (34 loc) · 1.11 KB
/
uninstall.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
param($installPath, $toolsPath, $package, $project)
Write-Host "Starting ExcelDna.AddIn uninstall script"
$isFSharpProject = ($project.Type -eq "F#")
$projectName = $project.Name
# Rename .dna file
$dnaFileName = "${projectName}-AddIn.dna"
$dnaFileItem = $project.ProjectItems | Where-Object { $_.Name -eq $dnaFileName }
if ($null -ne $dnaFileItem)
{
Write-Host "`tRenaming -AddIn.dna file"
# Try to rename the file
if ($null -eq ($project.ProjectItems | Where-Object { $_.Name -eq "_UNINSTALLED_${dnaFileName}" }))
{
$dnaFileItem.Name = "_UNINSTALLED_${dnaFileName}"
}
else
{
$suffix = 1
while ($null -ne ($project.ProjectItems | Where-Object { $_.Name -eq "_UNINSTALLED_${suffix}_${dnaFileName}" }))
{
$suffix++
}
$dnaFileItem.Name = "_UNINSTALLED_${suffix}_${dnaFileName}"
}
}
if ($isFSharpProject)
{
$project.Save("")
}
else
{
$project.Save()
}
Write-Host "Completed ExcelDna.AddIn uninstall script"