Update cake build to match NUnit 3 adapter
This commit is contained in:
Родитель
c0800a5458
Коммит
75a72fecd8
31
build.cake
31
build.cake
|
@ -1,5 +1,3 @@
|
|||
#tool nuget:?package=NUnit.Runners&version=2.6.4
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// ARGUMENTS
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -27,12 +25,31 @@ if (BuildSystem.IsRunningOnAppVeyor)
|
|||
}
|
||||
else
|
||||
{
|
||||
var buildNumber = AppVeyor.Environment.Build.Number;
|
||||
packageVersion = version + "-CI-" + buildNumber + dbgSuffix;
|
||||
if (AppVeyor.Environment.PullRequest.IsPullRequest)
|
||||
packageVersion += "-PR-" + AppVeyor.Environment.PullRequest.Number;
|
||||
var buildNumber = AppVeyor.Environment.Build.Number.ToString("00000");
|
||||
var branch = AppVeyor.Environment.Repository.Branch;
|
||||
var isPullRequest = AppVeyor.Environment.PullRequest.IsPullRequest;
|
||||
|
||||
if (branch == "master" && !isPullRequest)
|
||||
{
|
||||
packageVersion = version + "-dev-" + buildNumber + dbgSuffix;
|
||||
}
|
||||
else
|
||||
packageVersion += "-" + AppVeyor.Environment.Repository.Branch;
|
||||
{
|
||||
var suffix = "-ci-" + buildNumber + dbgSuffix;
|
||||
|
||||
if (isPullRequest)
|
||||
suffix += "-pr-" + AppVeyor.Environment.PullRequest.Number;
|
||||
else
|
||||
suffix += "-" + branch;
|
||||
|
||||
// Nuget limits "special version part" to 20 chars. Add one for the hyphen.
|
||||
if (suffix.Length > 21)
|
||||
suffix = suffix.Substring(0, 21);
|
||||
|
||||
suffix = suffix.Replace(".", "");
|
||||
|
||||
packageVersion = version + suffix;
|
||||
}
|
||||
}
|
||||
|
||||
AppVeyor.UpdateBuildVersion(packageVersion);
|
||||
|
|
54
build.ps1
54
build.ps1
|
@ -42,6 +42,7 @@ http://cakebuild.net
|
|||
Param(
|
||||
[string]$Script = "build.cake",
|
||||
[string]$Target = "Default",
|
||||
[ValidateSet("Release", "Debug")]
|
||||
[string]$Configuration = "Release",
|
||||
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
|
||||
[string]$Verbosity = "Verbose",
|
||||
|
@ -54,14 +55,43 @@ Param(
|
|||
[string[]]$ScriptArgs
|
||||
)
|
||||
|
||||
[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
|
||||
function MD5HashFile([string] $filePath)
|
||||
{
|
||||
if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf))
|
||||
{
|
||||
return $null
|
||||
}
|
||||
|
||||
[System.IO.Stream] $file = $null;
|
||||
[System.Security.Cryptography.MD5] $md5 = $null;
|
||||
try
|
||||
{
|
||||
$md5 = [System.Security.Cryptography.MD5]::Create()
|
||||
$file = [System.IO.File]::OpenRead($filePath)
|
||||
return [System.BitConverter]::ToString($md5.ComputeHash($file))
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ($file -ne $null)
|
||||
{
|
||||
$file.Dispose()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Preparing to run build script..."
|
||||
|
||||
$PSScriptRoot = split-path -parent $MyInvocation.MyCommand.Definition;
|
||||
if(!$PSScriptRoot){
|
||||
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
|
||||
}
|
||||
|
||||
$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
|
||||
$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
|
||||
$NUGET_URL = "http://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
|
||||
$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe"
|
||||
$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
|
||||
$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config"
|
||||
$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum"
|
||||
|
||||
# Should we use mono?
|
||||
$UseMono = "";
|
||||
|
@ -77,7 +107,7 @@ if($Experimental.IsPresent -and !($Mono.IsPresent)) {
|
|||
$UseExperimental = "-experimental"
|
||||
}
|
||||
|
||||
# Is this a dry run?d
|
||||
# Is this a dry run?
|
||||
$UseDryRun = "";
|
||||
if($WhatIf.IsPresent) {
|
||||
$UseDryRun = "-dryrun"
|
||||
|
@ -92,7 +122,7 @@ if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
|
|||
# Make sure that packages.config exist.
|
||||
if (!(Test-Path $PACKAGES_CONFIG)) {
|
||||
Write-Verbose -Message "Downloading packages.config..."
|
||||
try { Invoke-WebRequest -Uri http://cakebuild.net/download/bootstrapper/packages -OutFile $PACKAGES_CONFIG } catch {
|
||||
try { (New-Object System.Net.WebClient).DownloadFile("http://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch {
|
||||
Throw "Could not download packages.config."
|
||||
}
|
||||
}
|
||||
|
@ -125,11 +155,25 @@ $ENV:NUGET_EXE = $NUGET_EXE
|
|||
if(-Not $SkipToolPackageRestore.IsPresent) {
|
||||
Push-Location
|
||||
Set-Location $TOOLS_DIR
|
||||
|
||||
# Check for changes in packages.config and remove installed tools if true.
|
||||
[string] $md5Hash = MD5HashFile($PACKAGES_CONFIG)
|
||||
if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
|
||||
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
|
||||
Write-Verbose -Message "Missing or changed package.config hash..."
|
||||
Remove-Item * -Recurse -Exclude packages.config,nuget.exe
|
||||
}
|
||||
|
||||
Write-Verbose -Message "Restoring tools from NuGet..."
|
||||
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Throw "An error occured while restoring NuGet tools."
|
||||
}
|
||||
else
|
||||
{
|
||||
$md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
|
||||
}
|
||||
Write-Verbose -Message ($NuGetOutput | out-string)
|
||||
Pop-Location
|
||||
}
|
||||
|
@ -142,4 +186,4 @@ if (!(Test-Path $CAKE_EXE)) {
|
|||
# Start Cake
|
||||
Write-Host "Running build script..."
|
||||
Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs"
|
||||
exit $LASTEXITCODE
|
||||
exit $LASTEXITCODE
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NUnit" version="2.6.3" targetFramework="net45" />
|
||||
</packages>
|
|
@ -1,4 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Cake" version="0.13.0" />
|
||||
<package id="Cake" version="0.15.2" />
|
||||
<package id="NUnit.Runners" version="2.6.4" />
|
||||
</packages>
|
||||
|
|
Загрузка…
Ссылка в новой задаче