-
Notifications
You must be signed in to change notification settings - Fork 728
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70a1eb6
commit da3807e
Showing
3 changed files
with
152 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
## Pilferd from https://github.com/krlmlr/r-appveyor/blob/master/scripts/appveyor-tool.ps1 | ||
## Thanks to Kirill Müller | ||
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("Regsitrty update ok to value " + (Get-ItemProperty -Path $registryPath -Name $Name).ProductDir) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters