forked from alex-y-su/MethodDecorator
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.ps1
66 lines (51 loc) · 1.51 KB
/
install.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
param($installPath, $toolsPath, $package, $project)
function RemoveForceProjectLevelHack($project)
{
Foreach ($item in $project.ProjectItems)
{
if ($item.Name -eq "Fody_ToBeDeleted.txt")
{
$item.Delete()
}
}
}
function Update-FodyConfig($addinName, $project)
{
$fodyWeaversPath = [System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName($project.FullName), "FodyWeavers.xml")
$FodyLastProjectPath = $env:FodyLastProjectPath
$FodyLastWeaverName = $env:FodyLastWeaverName
$FodyLastXmlContents = $env:FodyLastXmlContents
if (
($FodyLastProjectPath -eq $project.FullName) -and
($FodyLastWeaverName -eq $addinName))
{
[System.IO.File]::WriteAllText($fodyWeaversPath, $FodyLastXmlContents)
return
}
$xml = [xml](get-content $fodyWeaversPath)
$weavers = $xml["Weavers"]
$node = $weavers.SelectSingleNode($addinName)
if (-not $node)
{
$newNode = $xml.CreateElement($addinName)
$weavers.AppendChild($newNode)
}
$xml.Save($fodyWeaversPath)
}
function Fix-ReferencesCopyLocal($package, $project)
{
$asms = $package.AssemblyReferences | %{$_.Name}
foreach ($reference in $project.Object.References)
{
if ($asms -contains $reference.Name + ".dll")
{
if($reference.CopyLocal -eq $true)
{
$reference.CopyLocal = $false;
}
}
}
}
RemoveForceProjectLevelHack $project
Update-FodyConfig $package.Id.Replace(".Fody", "") $project
Fix-ReferencesCopyLocal $package $project