forked from nunit/nunit
-
Notifications
You must be signed in to change notification settings - Fork 3
/
appveyor-tool.ps1
119 lines (105 loc) · 4.02 KB
/
appveyor-tool.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
Function Exec
{
[CmdletBinding()]
param (
[Parameter(Position=0, Mandatory=1)]
[scriptblock]$Command,
[Parameter(Position=1, Mandatory=0)]
[string]$ErrorMessage = "Execution of command failed.`n$Command"
)
$ErrorActionPreference = "Continue"
& $Command 2>&1 | %{ "$_" }
if ($LastExitCode -ne 0) {
throw "Exec: $ErrorMessage`nExit code: $LastExitCode"
}
}
Function Bootstrap {
[CmdletBinding()]
Param()
Progress "Bootstrap: Start"
if(!(Test-Administrator))
{
throw "Current executing user is not an administrator, please check your settings and try again."
}
Progress "Adding GnuWin32 tools to PATH"
$env:PATH = "C:\Program Files (x86)\Git\bin;" + $env:PATH
InstallCFTools
Progress "Bootstrap: Done"
}
Function InstallCFTools {
[CmdletBinding()]
Param()
$url= "https://github.com/dicko2/CompactFrameworkBuildBins/raw/master/NETCFSetupv35.msi";
Progress ("Downloading NETCFSetupv35 from: " + $url)
Invoke-WebRequest -Uri $url -OutFile NETCFSetupv35.msi
$url= "https://github.com/dicko2/CompactFrameworkBuildBins/raw/master/NETCFv35PowerToys.msi";
Progress ("Downloading NETCFv35PowerToys from: " + $url)
Invoke-WebRequest -Uri $url -OutFile NETCFv35PowerToys.msi
Progress("Running NETCFSetupv35 installer")
$msi = @("NETCFSetupv35.msi","NETCFv35PowerToys.msi")
foreach ($msifile in $msi)
{
if(!(Test-Path($msi)))
{
throw "MSI files are not present, please check logs."
}
Progress("Installing msi " + $msifile )
Start-Process -FilePath "$env:systemroot\system32\msiexec.exe" -ArgumentList "/i `"$msifile`" /qn /norestart" -Wait -WorkingDirectory $pwd -RedirectStandardOutput stdout.txt -RedirectStandardError stderr.txt
$OutputText = get-content stdout.txt
Progress($OutputText)
$OutputText = get-content stderr.txt
Progress($OutputText)
}
if(!(Test-Path("C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.CompactFramework.CSharp.targets")))
{
throw "Compact framework files not found after install, install may have failed, please check logs."
}
RegistryWorkAround
}
Function Progress
{
[CmdletBinding()]
param (
[Parameter(Position=0, Mandatory=0)]
[string]$Message = ""
)
$ProgressMessage = '== ' + (Get-Date) + ': ' + $Message
Write-Host $ProgressMessage -ForegroundColor Magenta
}
function Test-Administrator
{
$user = [Security.Principal.WindowsIdentity]::GetCurrent();
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
function RegistryWorkAround
{
## http://community.sharpdevelop.net/forums/t/10548.aspx
## see above link for work around for error
## The "AddHighDPIResource" task failed unexpectedly.
## System.ArgumentNullException: Value cannot be null.
## Parameter name: path1
$registryPaths = @("HKLM:\SOFTWARE\Microsoft\VisualStudio\9.0\Setup\VS","HKLM:\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\Setup\VS")
## not last reply in forum post about needing the entry in WOW is why there is two paths
$Name = "ProductDir"
$value = "C:\Program Files (x86)\Microsoft Visual Studio 9.0"
foreach($registryPath in $registryPaths)
{
If(!(Test-Path $registryPath))
{
New-Item -Path $registryPath -Force | Out-Null
}
If(!(Test-Path $registryPath+"\"+$Name))
{
New-ItemProperty -Path $registryPath -Name $name -Value $value `
-PropertyType String -Force | Out-Null
}
If(!((Get-ItemProperty -Path $registryPath -Name $Name).ProductDir -eq "C:\Program Files (x86)\Microsoft Visual Studio 9.0"))
{
throw "Registry path " + $registryPath + " not set to correct value, please check logs"
}
else
{
Progress("Registry update ok to value " + (Get-ItemProperty -Path $registryPath -Name $Name).ProductDir)
}
}
}