Skip to content

Commit

Permalink
Release Microsoft.Build.RunVSTest
Browse files Browse the repository at this point in the history
  • Loading branch information
dfederm committed Apr 1, 2024
1 parent fb0a2ba commit d52fe5a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 53 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
63 changes: 11 additions & 52 deletions src/RunTests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,31 @@

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
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Sdk Name="Microsoft.Build.RunVSTest"/>
...
</Project>
```

## For projects that use packages references. In your `Directory.Packages.props`:
```xml
<Project>
...
<ItemGroup>
<PackageVersion Include="Microsoft.Build.RunVSTest" Version="1.0.0" />
</ItemGroup>
</Project>
```

```
<Project>
<ItemGroup>
<PackageReference Include="Microsoft.Build.RunVSTest" Version="1.0.0" />
</ItemGroup>
</Project>
```
## 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
```
<Project Sdk="Microsoft.Build.Traversal">
<ItemGroup>
<ProjectFile Include="ConsoleApp1\ConsoleApp1.csproj" />
<ProjectFile Include="CPPUnitTest1\CPPUnitTest1.vcxproj" Test="true" />
<ProjectFile Include="CSharpTestProject1\CSharpTestProject1.csproj" Test="true" />
<ProjectFile Include="CSharpTestProject2\CSharpTestProject2.csproj" Test="true" />
</ItemGroup>
</Project>
```xml
<Sdk Name="Microsoft.Build.RunVSTest" Version="1.0.0" />
```

## Sln
```
Alternately, if all projects in the repo support packages references, in `Directory.Packages.props`:
```xml
<Project>
<ItemGroup>
<PackageReference Include="Microsoft.Build.RunVSTest" Version="1.0.0" />
<GlobalPackageReference Include="Microsoft.Build.RunVSTest" Version="1.0.0" />
</ItemGroup>
</Project>
```

## 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 invocatino can be significantly faster than building and then in serial running tests after.
2 changes: 1 addition & 1 deletion src/RunTests/version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"inherit": false,
"inherit": true,
"version": "1.0"
}

0 comments on commit d52fe5a

Please sign in to comment.