This post was originally published on Marcel de Vries' blog at Execute and publish xUnit Tests results with .NET Core and VSTS.

At the moment of writing you can not use the standard Visual studio tests task to run your xUnit unit tests on DotNetCore 1.0 and then publish the results to VSTS.

You need some different steps to get DotnetCore compiled and run your unit tests in a VSTS build. Here are the steps to make it work:

Pick the standard Visual studio template for your build:


In this default build workflow first add a command line to run a dotnet restore command so your build of your solution will succeed. do this right after the nuget restore step:


In the command line options set the tool to : dotnet and the command line argument to: restore


Now our solution should build.  The next step is to replace the Test assemblies task since in dotnet core you run your unit tests also using the dotnet command line. So we replace this task with a new command line task and provide it the following arguments:

test $(Build.Repository.LocalPath)<locationoftestproject> –no-build -xml testresults.xml

Of course here you replace <locationoftestproject> with the correct location of the project containing your unit tests. In my case I was using the MVC music store sample project (which can be found here: )and for this I needed to replace the test location to: testMusicStore.Test

Note that the additional arguments instruct the framework not to build the solution again, since we already have done this and would be a waste of time. The –xml option provides the name of the xml test results file that we want as output so we can publish the results to VSTS.


Now we have run the tests, so the final step is to publish the results to VSTS. For this we use the Publish test results task


And for this task we need to provide the name of the file it needs to publish. this is of course the name of the file we specified as the –xml output. We also need to specify that the results file contains test results in the xUnit format. Default it is set to use the JUnit format. But this is a simple select from the dropdown test Result Format.

So the final settings for the Publish task should look like this:


Now we can run our build and you will see the following results appear:


As you can see our tests are run and nicely reported. In this screenshot I switched to the tests tab in the results views that are available for a build and changed the outcome to show all results. Here you can see all de details of every test you have, when they have started failing, and how long they run.

As you can see all integrates nicely, only not with our default Visual Studio test task. I assume we might see this integrated in the future when we get new releases of the build tools for DotNet Core, but for now this is a pretty nice and clean solution to get things up and running.