diff --git a/README.md b/README.md index 7c31520..1653881 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,12 @@ Supports staging artifacts from build outputs. Enables Copy on Write for faster file copies. +### [Microsoft.Build.RunVSTest](src/RunTests) +[![NuGet](https://img.shields.io/nuget/v/Microsoft.Build.RunVSTest.svg)](https://www.nuget.org/packages/Microsoft.Build.RunVSTest) + [![NuGet](https://img.shields.io/nuget/dt/Microsoft.Build.RunVSTest.svg)](https://www.nuget.org/packages/Microsoft.Build.RunVSTest) + +Hooks VSTest to the Test target, allowing running tests concurrently with the build via `msbuild /t:Build;Test`. + ## How can I use these SDKs? When using an MSBuild Project SDK obtained via NuGet (such as the SDKs in this repo) a specific version **must** be specified. diff --git a/src/RunTests/README.md b/src/RunTests/README.md index e3d54d9..aec3c39 100644 --- a/src/RunTests/README.md +++ b/src/RunTests/README.md @@ -2,72 +2,69 @@ The `Microsoft.Build.RunVSTest` MSBuild SDK adds support for running tests from MSBuild, similarly to how one would use `dotnet test`. -## For projects that cannot use package references such as vcxproj. Usage in `Directory.Packages.Props` -In your global.json add the following: -```json -{ - "msbuild-sdks": { - "Microsoft.Build.RunVSTest": "1.0.0" - } -} -``` -In your ..vcxproj file -```xml - - - ... - -``` - -## For projects that use packages references. In your `Directory.Packages.props`: -```xml - -... - - - - -``` +Note: this SDK defers to the built-in test mechanism when using `dotnet` and simply sets `$(UseMSBuildTestInfrastructure)` to `true`. This SDK is primarily intended for scenarios which use msbuild.exe, the Visual Studio flavor of MSBuild. When using `dotnet`, you can already do `dotnet msbuild /t:Build;Test /p:UseMSBuildTestInfrastructure=true` (or set the property in `Directory.Build.props`) to get this behavior. -``` - - - - - -``` +## Usage -This example will include the `Microsoft.Build.RunVSTest` task for all NuGet-based projects in your repo. +In `Directory.Build.props`: -## Dirs.proj example -Use with traversal project -``` - - - - - - - - +```xml + ``` -## Sln -``` +Alternately, if all projects in the repo support packages references, in `Directory.Packages.props`: +```xml - + ``` -## Example -To run tests +Then to run tests: ``` msbuild /t:Test ``` -To build and run tests +Or build and run tests ``` msbuild /t:Build;Test ``` + +Note that running build and tests together in a single MSBuild invocation can be significantly faster than building and then in serial running tests after. + +## Extensibility + +Setting the following properties control how the SDK works. + +| Property | Description | +|-------------------------------------|-------------| +| `VSTestToolExe` | Overrides the exe name for vstest. By default, `vstest.console.exe` is used. | +| `VSTestToolPath` | Overrides which directory in which to look for the vstest tool. By default, the SDK looks in `%VSINSTALLDIR%\Common7\IDE\CommonExtensions\Microsoft\TestWindow\` | + +There are also various properties which map to VSTest.Console [command-line options](https://learn.microsoft.com/en-us/visualstudio/test/vstest-console-options). + +| Property | VSTest argument | +|-------------------------------------|-----------------| +| `VSTestSetting` | `--settings` | +| `VSTestTestAdapterPath` | `--testAdapterPath` | +| `VSTestFramework` | `--framework` | +| `VSTestPlatform` | `--platform` | +| `VSTestTestCaseFilter` | `--testCaseFilter` | +| `VSTestLogger` | `--logger` | +| `VSTestListTests` | `--listTests` | +| `VSTestDiag` | `--Diag` | +| `VSTestResultsDirectory` | `--resultsDirectory` | +| `VSTestVerbosity` | `--logger:Console;Verbosity=` | +| `VSTestCollect` | `--collect` | +| `VSTestBlame` (bool) | `--Blame` | +| `VSTestBlameCrash` (bool) | `CollectDump` argument for `--Blame` | +| `VSTestBlameCrashDumpType` | `DumpType` argument for `--Blame` | +| `VSTestBlameCrashCollectAlways` | `CollectAlways` argument for `--Blame` | +| `VSTestBlameHang` (bool) | `CollectHangDump` argument for `--Blame` | +| `VSTestBlameHangDumpType` | `HangDumpType` argument for `--Blame` | +| `VSTestBlameHangTimeout` | `TestTimeout` argument for `--Blame` | +| `VSTestTraceDataCollectorDirectoryPath` | `--testAdapterPath` | +| `VSTestNoLogo` (bool) | `--nologo` | +| `VSTestArtifactsProcessingMode` (value `collect`) | `--artifactsProcessingMode-collect` | +| `VSTestSessionCorrelationId` | `--testSessionCorrelationId` | diff --git a/src/RunTests/version.json b/src/RunTests/version.json index 991aada..5157e3f 100644 --- a/src/RunTests/version.json +++ b/src/RunTests/version.json @@ -1,4 +1,4 @@ { - "inherit": false, + "inherit": true, "version": "1.0" }