forked from sstronin/MethodDecorator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.ps1
47 lines (34 loc) · 1.19 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
39
40
41
42
43
44
45
46
47
param($installPath, $toolsPath, $package, $project)
function Update-FodyConfig($addinName, $project)
{
$fodyWeaversPath = [System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName($project.FullName), "FodyWeavers.xml")
if (!(Test-Path ($fodyWeaversPath)))
{
return
}
Write-Host "Caching variables for possible update"
$env:FodyLastProjectPath = $project.FullName
$env:FodyLastWeaverName = $addinName
$env:FodyLastXmlContents = [IO.File]::ReadAllText($fodyWeaversPath)
$xml = [xml](get-content $fodyWeaversPath)
$weavers = $xml["Weavers"]
$node = $weavers.SelectSingleNode($addinName)
if ($node)
{
Write-Host "Removing node from FodyWeavers.xml"
$weavers.RemoveChild($node)
}
$xml.Save($fodyWeaversPath)
}
function UnlockWeaversXml($project)
{
$fodyWeaversProjectItem = $project.ProjectItems.Item("FodyWeavers.xml");
if ($fodyWeaversProjectItem)
{
$fodyWeaversProjectItem.Open("{7651A701-06E5-11D1-8EBD-00A0C90F26EA}")
$fodyWeaversProjectItem.Save()
$fodyWeaversProjectItem.Document.Close()
}
}
UnlockWeaversXml($project)
Update-FodyConfig $package.Id.Replace(".Fody", "") $project