Skip to content

Commit

Permalink
Changes for CF build
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldickson committed Mar 1, 2016
1 parent 70a1eb6 commit da3807e
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 2 deletions.
121 changes: 121 additions & 0 deletions appveyor-tool.ps1
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)
}
}
}
7 changes: 6 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ branches:
except:
- /travis-.*/

install:
ps: |
Import-Module '.\appveyor-tool.ps1'
Bootstrap
before_build:
- nuget restore nunit.sln

build_script:
- ps: .\build.ps1 -Target "Appveyor"

artifacts:
- path: package\*.nupkg
# - path: package\*.msi
Expand Down
26 changes: 25 additions & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ Task("BuildAllFrameworks")
.Does(() =>
{
foreach (var runtime in AllFrameworks)
if (runtime != "netcf-3.5")
BuildFramework(configuration, runtime);
});

Expand Down Expand Up @@ -575,6 +574,16 @@ void BuildFramework(string configuration, string framework)
BuildProject("src/NUnitFramework/nunitlite.tests/nunitlite.tests-sl-5.0.csproj", configuration, MSBuildPlatform.x86);
BuildProject("src/NUnitFramework/nunitlite-runner/nunitlite-runner-sl-5.0.csproj", configuration, MSBuildPlatform.x86);
break;
case "netcf-3.5":
BuildProjectCF("src/NUnitFramework/framework/nunit.framework-netcf-3.5.csproj", configuration);
BuildProjectCF("src/NUnitFramework/testdata/nunit.testdata-netcf-3.5.csproj", configuration);
BuildProjectCF("src/NUnitFramework/tests/nunit.framework.tests-netcf-3.5.csproj", configuration);
BuildProjectCF("src/NUnitFramework/mock-assembly/mock-assembly-netcf-3.5.csproj", configuration);
BuildProjectCF("src/NUnitFramework/slow-tests/slow-nunit-tests-netcf-3.5.csproj", configuration);
BuildProjectCF("src/NUnitFramework/nunitlite.tests/nunitlite.tests-netcf-3.5.csproj", configuration);
BuildProjectCF("src/NUnitFramework/nunitlite/nunitlite-netcf-3.5.csproj", configuration);
BuildProjectCF("src/NUnitFramework/nunitlite-runner/nunitlite-runner-netcf-3.5.csproj", configuration);
break;
}
}

Expand Down Expand Up @@ -617,6 +626,21 @@ void BuildProject(string projectPath, string configuration)
BuildProject(projectPath, configuration, MSBuildPlatform.Automatic);
}

void BuildProjectCF(string projectPath, string configuration)
{
if(IsRunningOnWindows())
{
// Use MSBuild
MSBuild(projectPath, new MSBuildSettings()
.SetConfiguration(configuration)
.SetMSBuildPlatform(MSBuildPlatform.x86)
.SetVerbosity(Verbosity.Minimal)
.SetNodeReuse(false)
.UseToolVersion(MSBuildToolVersion.VS2008)
);
}
}

void BuildProject(string projectPath, string configuration, MSBuildPlatform buildPlatform)
{
if(IsRunningOnWindows())
Expand Down

0 comments on commit da3807e

Please sign in to comment.