зеркало из
1
0
Форкнуть 0
This commit is contained in:
Charlie Poole 2017-12-19 09:37:01 -08:00
Родитель 36b30a3eeb
Коммит 347fc6d068
4 изменённых файлов: 356 добавлений и 0 удалений

13
appveyor.yml Normal file
Просмотреть файл

@ -0,0 +1,13 @@
version: 3.9.{build}
image: Visual Studio 2017
build_script:
- ps: .\build.ps1 -Target "Appveyor"
# disable built-in tests.
test: off
# Holds the build machine open and displays information on how to RDP into the box.
# Useful for figuring out why your builds are not working, but comment out when you are done :)
#on_finish:
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

253
build.cake Normal file
Просмотреть файл

@ -0,0 +1,253 @@
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
//////////////////////////////////////////////////////////////////////
// DEFINE RUN CONSTANTS
//////////////////////////////////////////////////////////////////////
// Directories
var PROJECT_DIR = Context.Environment.WorkingDirectory.FullPath + "/";
var VS2015_DIR = PROJECT_DIR + "solutions/vs2015/";
var VS2017_DIR = PROJECT_DIR + "solutions/vs2017/";
var TOOLS_DIR = PROJECT_DIR + "tools/";
var NET35_ADAPTER_PATH = TOOLS_DIR + "NUnit3TestAdapter/build/net35/";
// Version of the Adapter to Use
var ADAPTER_VERSION = "3.9.0";
// Specify all the demo projects
var DemoProjects = new DemoProject[] {
new DemoProject()
{
Path = VS2015_DIR + "CSharpTestDemo/CSharpTestDemo.csproj",
OutputDir = VS2015_DIR + "CSharpTestDemo/bin/" + configuration + "/",
ExpectedResult = "Total tests: 107. Passed: 58. Failed: 25. Skipped: 15."
},
new DemoProject()
{
Path = VS2015_DIR + "VbTestDemo/VbTestDemo.vbproj",
OutputDir = VS2015_DIR + "VbTestDemo/bin/" + configuration + "/",
ExpectedResult = "Total tests: 107. Passed: 58. Failed: 25. Skipped: 15."
},
new DemoProject()
{
Path = VS2015_DIR + "CppTestDemo/CppTestDemo.vcxproj",
OutputDir = VS2015_DIR + "CppTestDemo/" + configuration + "/",
ExpectedResult = "Total tests: 29. Passed: 13. Failed: 6. Skipped: 8."
},
new DemoProject()
{
Path = VS2017_DIR + "NUnitTestDemo/NUnit3TestDemo.csproj",
OutputDir = VS2017_DIR + "NUnitTestDemo/bin/" + configuration + "/",
ExpectedResult = "Total tests: 107. Passed: 58. Failed: 25. Skipped: 15."
},
new DemoProject()
{
Path = VS2017_DIR + "NUnit3CoreTestDemo/NUnit3CoreTestDemo.csproj",
OutputDir = VS2017_DIR + "NUnit3CoreTestDemo/bin/" + configuration + "/",
ExpectedResult = "Total tests: 107. Passed: 58. Failed: 25. Skipped: 15."
}
};
//////////////////////////////////////////////////////////////////////
// CLEAN
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
foreach(var proj in DemoProjects)
CleanDirectory(proj.OutputDir);
});
//////////////////////////////////////////////////////////////////////
// NUGET RESTORE
//////////////////////////////////////////////////////////////////////
Task("NuGetRestore")
.Does(() =>
{
foreach (var proj in DemoProjects)
{
if (proj.SupportsRestore)
{
Information("Restoring NuGet Packages for " + proj.Name);
if (proj.Name.Contains("Core"))
DotNetCoreRestore(proj.Path);
else
{
NuGetRestore(proj.Path,
new NuGetRestoreSettings {
PackagesDirectory = System.IO.Path.GetDirectoryName(proj.Path) + "/packages"
});
}
}
}
});
//////////////////////////////////////////////////////////////////////
// BUILD
//////////////////////////////////////////////////////////////////////
Task("Build")
.IsDependentOn("NugetRestore")
.Does(() =>
{
foreach (var proj in DemoProjects)
{
MSBuild(proj.Path, new MSBuildSettings
{
Configuration = configuration,
EnvironmentVariables = new Dictionary<string, string>(),
NodeReuse = false,
PlatformTarget = PlatformTarget.MSIL,
ToolVersion = proj.ToolVersion
});
}
});
//////////////////////////////////////////////////////////////////////
// INSTALL ADAPTER
//////////////////////////////////////////////////////////////////////
Task("InstallAdapter")
.Does(() =>
{
Information("Installing NUnit3TestAdapter");
NuGetInstall("NUnit3TestAdapter",
new NuGetInstallSettings()
{
OutputDirectory = TOOLS_DIR,
Version = ADAPTER_VERSION,
ExcludeVersion = true
});
});
//////////////////////////////////////////////////////////////////////
// RUN DEMOS
//////////////////////////////////////////////////////////////////////
Task("RunDemos")
.IsDependentOn("Build")
.IsDependentOn("InstallAdapter")
.Does(() =>
{
foreach(var proj in DemoProjects)
{
Information("");
Information("********************************************************************************************");
Information("Demo: " + proj.TestAssembly);
Information("********************************************************************************************");
Information("");
if (!proj.Name.Contains("Core"))
{
IEnumerable<string> redirectedStandardOutput;
IEnumerable<string> redirectedErrorOutput;
int result = StartProcess(
"vstest.console.exe",
new ProcessSettings()
{
Arguments = $"{proj.TestAssembly} /TestAdapterPath:{NET35_ADAPTER_PATH}",
RedirectStandardOutput = true
},
out redirectedStandardOutput,
out redirectedErrorOutput);
foreach(string line in redirectedStandardOutput)
{
Information(line);
if (line.StartsWith("Total tests"))
proj.ActualResult = line;
}
}
else
{
Information("Skipping .NET Core demo for now");
proj.SkipReason = ".NET Core Project";
}
}
Information("");
Information("******************************");
Information("* Test Demo Summary Report *");
Information("******************************");
Information("");
foreach (var proj in DemoProjects)
{
Information(proj.Path);
if (proj.SkipReason != null)
{
Information(" Skipped: " + proj.SkipReason);
}
else
if (proj.ActualResult == proj.ExpectedResult)
{
Information(" Passed: " + proj.ExpectedResult);
}
else
{
Information("Expected: " + proj.ExpectedResult);
Information(" But was: " + proj.ActualResult ?? "<null>");
}
Information("");
}
});
public class DemoProject
{
public string Path { get; set; }
public string OutputDir { get; set; }
public string ExpectedResult { get; set; }
public string ActualResult { get; set; }
public string SkipReason { get; set; }
public string Name
{
get { return System.IO.Path.GetFileNameWithoutExtension(Path); }
}
public string Type
{
get { return System.IO.Path.GetExtension(Path); }
}
public string TestAssembly
{
get { return OutputDir + Name + ".dll"; }
}
public bool SupportsRestore
{
get { return Type != ".vcxproj"; }
}
public MSBuildToolVersion ToolVersion
{
get { return Path.Contains("vs2015") ? MSBuildToolVersion.VS2015 : MSBuildToolVersion.VS2017; }
}
}
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Appveyor")
.IsDependentOn("RunDemos");
Task("Default")
.IsDependentOn("Build");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);

2
build.cmd Normal file
Просмотреть файл

@ -0,0 +1,2 @@
@echo off
powershell ./build.ps1 %CAKE_ARGS% %*

88
build.ps1 Normal file
Просмотреть файл

@ -0,0 +1,88 @@
<#
.SYNOPSIS
This is a Powershell script to bootstrap a Cake build.
.DESCRIPTION
This Powershell script will download NuGet if missing, restore NuGet tools (including Cake)
and execute your Cake build script with the parameters you provide.
.PARAMETER Target
The build script target to run.
.PARAMETER Configuration
The build configuration to use.
.PARAMETER Verbosity
Specifies the amount of information to be displayed.
.PARAMETER WhatIf
Performs a dry run of the build script.
No tasks will be executed.
.PARAMETER ScriptArgs
Remaining arguments are added here.
.LINK
https://cakebuild.net
#>
[CmdletBinding()]
Param(
[string]$Target = "Default",
[ValidateSet("Release", "Debug")]
[string]$Configuration = "Release",
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
[string]$Verbosity = "Verbose",
[switch]$WhatIf,
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$ScriptArgs
)
$CakeVersion = "0.23.0"
$NugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
# Temporarily skip verification and opt-in to new in-proc NuGet
$ENV:CAKE_NUGET_USEINPROCESSCLIENT='true'
# Make sure tools folder exists
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
$ToolPath = Join-Path $PSScriptRoot "tools"
if (!(Test-Path $ToolPath)) {
Write-Verbose "Creating tools directory..."
New-Item -Path $ToolPath -Type directory | out-null
}
###########################################################################
# INSTALL NUGET
###########################################################################
# Make sure nuget.exe exists.
$NugetPath = Join-Path $ToolPath "nuget.exe"
if (!(Test-Path $NugetPath)) {
Write-Host "Downloading NuGet.exe..."
(New-Object System.Net.WebClient).DownloadFile($NugetUrl, $NugetPath);
}
###########################################################################
# INSTALL CAKE
###########################################################################
# Make sure Cake has been installed.
$CakePath = Join-Path $ToolPath "Cake.$CakeVersion/Cake.exe"
if (!(Test-Path $CakePath)) {
Write-Host "Installing Cake..."
Invoke-Expression "&`"$NugetPath`" install Cake -Version $CakeVersion -OutputDirectory `"$ToolPath`"" | Out-Null;
if ($LASTEXITCODE -ne 0) {
Throw "An error occurred while restoring Cake from NuGet."
}
}
###########################################################################
# RUN BUILD SCRIPT
###########################################################################
# Build the argument list.
$Arguments = @{
target=$Target;
configuration=$Configuration;
verbosity=$Verbosity;
dryrun=$WhatIf;
}.GetEnumerator() | %{"--{0}=`"{1}`"" -f $_.key, $_.value };
# Start Cake
Write-Host "Running build script..."
Invoke-Expression "& `"$CakePath`" `"build.cake`" $Arguments $ScriptArgs"
exit $LASTEXITCODE