Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/Microsoft.DotNet.Arcade.Sdk/tools/DefaultVersions.props
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
<PropertyGroup>
<!-- Opt-out features -->
<UsingToolXliff Condition="'$(UsingToolXliff)' == ''">true</UsingToolXliff>
<UsingToolXUnit Condition="'$(UsingToolXUnit)' == ''">true</UsingToolXUnit>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UsingToolXUnit [](start = 5, length = 14)

It seems we are still using this property. We also use UsingToolVSTest now. Both should be listed here with their defaults (either opt-in or opt-out).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am only reading UsingToolXUnit as a back-compat for cases where it was set to false for some reason. I will add UsingToolVSTest here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still should be here, perhaps with a comment. It is useful to see all the values here for reference.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UsingToolVSTest is a bit more strange too. Its default changes based on what test framework you are using. Its false by default if you are using XUnit, but it is required to be true if using another test framework.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So then I'm not sure naming it UsingToolXxx is appropriate. These switches are used for repository-wide configuration, not something that should differ project to project.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will name it UseVSTestRunner then.

<UsingToolPdbConverter Condition="'$(UsingToolPdbConverter)' == ''">true</UsingToolPdbConverter>

<!-- Opt-in features -->
Expand All @@ -46,6 +45,13 @@
<UsingToolNuGetRepack Condition="'$(UsingToolNuGetRepack)' == ''">false</UsingToolNuGetRepack>
<UsingToolSymbolUploader Condition="'$(UsingToolSymbolUploader)' == ''">false</UsingToolSymbolUploader>

<!-- Deprecated features -->
<!--
The UsingToolXUnit property is deprecated,
use the TestRunnerName property to choose which test runner to use.
-->
<UsingToolXUnit Condition="'$(UsingToolXUnit)' == ''">true</UsingToolXUnit>

<!--
Use compilers from the Microsoft.Net.Compilers/Microsoft.NETCore.Compilers package.
Repo can set this property to true if it needs to use a different version of the compiler than the one in the dotnet SDK.
Expand Down Expand Up @@ -78,11 +84,17 @@
<MicrosoftVSSDKBuildToolsVersion Condition="'$(MicrosoftVSSDKBuildToolsVersion)' == ''">15.1.192</MicrosoftVSSDKBuildToolsVersion>
<MicrosoftDotnetNuGetRepackTasksVersion Condition="'$(MicrosoftDotnetNuGetRepackTasksVersion)' == ''">$(ArcadeSdkVersion)</MicrosoftDotnetNuGetRepackTasksVersion>
<MicrosoftDotNetSignToolVersion Condition="'$(MicrosoftDotNetSignToolVersion)' == ''">$(ArcadeSdkVersion)</MicrosoftDotNetSignToolVersion>
<MicrosoftTestPlatformVersion Condition="'$(MicrosoftTestPlatformVersion)' == ''">16.5.0</MicrosoftTestPlatformVersion>
<XUnitVersion Condition="'$(XUnitVersion)' == ''">2.4.1</XUnitVersion>
<XUnitRunnerConsoleVersion Condition="'$(XUnitRunnerConsoleVersion)' == ''">$(XUnitVersion)</XUnitRunnerConsoleVersion>
<XUnitRunnerVisualStudioVersion Condition="'$(XUnitRunnerVisualStudioVersion)' == ''">$(XUnitVersion)</XUnitRunnerVisualStudioVersion>
<MSTestVersion Condition="'$(MSTestVersion)' == ''">2.0.0</MSTestVersion>
<MSTestTestAdapterVersion Condition="'$(MSTestTestAdapterVersion)' == ''">$(MSTestVersion)</MSTestTestAdapterVersion>
<MSTestTestFrameworkVersion Condition="'$(MSTestTestFrameworkVersion)' == ''">$(MSTestVersion)</MSTestTestFrameworkVersion>
<MicrosoftDotNetBuildTasksFeedVersion Condition="'$(MicrosoftDotNetBuildTasksFeedVersion)' == ''">$(ArcadeSdkVersion)</MicrosoftDotNetBuildTasksFeedVersion>
<MicrosoftSymbolUploaderBuildTaskVersion Condition="'$(MicrosoftSymbolUploaderBuildTaskVersion)' == ''">1.0.0-beta-65130-01</MicrosoftSymbolUploaderBuildTaskVersion>
<NUnitVersion Condition="'$(NUnitVersion)' == ''">3.12.0</NUnitVersion>
<NUnit3TestAdapterVersion Condition="'$(NUnit3TestAdapterVersion)' == ''">3.15.1</NUnit3TestAdapterVersion>
<VSWhereVersion Condition="'$(VSWhereVersion)' == ''">2.6.7</VSWhereVersion>
<SNVersion Condition="'$(SNVersion)' == ''">1.0.0</SNVersion>
<MicrosoftDotNetBuildTasksVisualStudioVersion Condition="'$(MicrosoftDotNetBuildTasksVisualStudioVersion)' == ''">$(ArcadeSdkVersion)</MicrosoftDotNetBuildTasksVisualStudioVersion>
Expand Down
11 changes: 11 additions & 0 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/MSTest/MSTest.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Project>
<ItemGroup>
<PackageReference Include="Microsoft.TestPlatform" Version="$(MicrosoftTestPlatformVersion)" IsImplicitlyDefined="true" PrivateAssets="all" Publish="true"/>
<PackageReference Include="MSTest.TestFramework" Version="$(MSTestTestFrameworkVersion)" IsImplicitlyDefined="true" PrivateAssets="all" Publish="true"/>
<PackageReference Include="MSTest.TestAdapter" Version="$(MSTestTestAdapterVersion)" IsImplicitlyDefined="true" PrivateAssets="all" Publish="true"/>
</ItemGroup>

<Import Project="..\VSTest.targets"/>
</Project>
11 changes: 11 additions & 0 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/NUnit/NUnit.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Project>
<ItemGroup>
<PackageReference Include="Microsoft.TestPlatform" Version="$(MicrosoftTestPlatformVersion)" IsImplicitlyDefined="true" PrivateAssets="all" Publish="true"/>
<PackageReference Include="NUnit" Version="$(NUnitVersion)" IsImplicitlyDefined="true" PrivateAssets="all" Publish="true"/>
<PackageReference Include="NUnit3TestAdapter" Version="$(NUnit3TestAdapterVersion)" IsImplicitlyDefined="true" PrivateAssets="all" Publish="true"/>
</ItemGroup>

<Import Project="..\VSTest.targets"/>
</Project>
6 changes: 0 additions & 6 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/Tests.props
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,7 @@
<!-- Treat test assemblies as non-shipping (do not publish or sign them). -->
<IsShipping Condition="'$(IsShipping)' == ''">false</IsShipping>

<!-- Default test runner -->
<TestRunnerName Condition="'$(UsingToolXUnit)' == 'true'">XUnit</TestRunnerName>

<!-- exclude test projects from source-build by default -->
<ExcludeFromSourceBuild Condition="'$(ExcludeFromSourceBuild)' == ''">true</ExcludeFromSourceBuild>
</PropertyGroup>

<!-- Import specialized props files of supported test runners -->
<Import Project="$(MSBuildThisFileDirectory)$(TestRunnerName)\$(TestRunnerName).props" Condition="'$(TestRunnerName)' != '' and Exists('$(MSBuildThisFileDirectory)$(TestRunnerName)\$(TestRunnerName).props')"/>
</Project>
16 changes: 13 additions & 3 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/Tests.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Project>
<Project InitialTargets="ErrorForMissingTestRunner">

<PropertyGroup Condition="'$(IsTestProject)' == 'true'">
<AutoGenerateBindingRedirects Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">true</AutoGenerateBindingRedirects>
Expand All @@ -12,8 +12,18 @@
<TestRuntime Condition="'$(TestRuntime)' == '' and '$(TargetFrameworkIdentifier)' == '.NETCoreApp'">Core</TestRuntime>
<TestRuntime Condition="'$(TestRuntime)' == '' and '$(MSBuildRuntimeType)' == 'Mono'">Mono</TestRuntime>
<TestRuntime Condition="'$(TestRuntime)' == '' and '$(OS)' == 'Windows_NT'">Full</TestRuntime>

<TestRunnerName Condition="'$(TestRunnerName)' == ''">XUnit</TestRunnerName>
<TestRunnerName Condition="'$(UsingToolXUnit)' == 'false'"></TestRunnerName>

<TestRunnerTargets>$(MSBuildThisFileDirectory)$(TestRunnerName)\$(TestRunnerName).targets</TestRunnerTargets>
</PropertyGroup>

<Target Name="ErrorForMissingTestRunner"
Condition="'$(IsTestProject)' == 'true' AND '$(TestRunnerName)' != ''">
<Error Condition="!Exists($(TestRunnerTargets))" Text="Test runner $(TestRunnerName) is invalid."/>
</Target>

<PropertyGroup Condition="'$(IsTestProject)' == 'true' and '$(TestArchitectures)' == ''">
<TestArchitectures>$(PlatformTarget)</TestArchitectures>
<TestArchitectures Condition="'$(PlatformTarget)' == '' or '$(PlatformTarget)' == 'AnyCpu'">x64</TestArchitectures>
Expand All @@ -28,8 +38,7 @@

<!-- Using Inputs/Outputs just to loop over test architectures -->
<Target Name="_InnerGetTestsToRun"
Inputs="*%(_TestArchitectureItems.Identity)"
Outputs="*%(_TestArchitectureItems.Identity)"
Outputs="%(_TestArchitectureItems.Identity)"
Returns="@(TestToRun)"
Condition="'$(TestRuntime)' != '' and '$(SkipTests)' != 'true' and
('$(TestTargetFrameworks)' == '' or $([System.String]::new(';$(TestTargetFrameworks);').Contains(';$(TargetFramework);')))">
Expand All @@ -43,6 +52,7 @@
<TestToRun Include="$(TargetPath)">
<TargetFramework>$(TargetFramework)</TargetFramework>
<TargetFrameworkIdentifier>$(TargetFrameworkIdentifier)</TargetFrameworkIdentifier>
<TargetFrameworkVersion>$(TargetFrameworkVersion)</TargetFrameworkVersion>
<TestRuntime>$(TestRuntime)</TestRuntime>
<TestTimeout>$(TestTimeout)</TestTimeout>
<Architecture>$(_TestArchitecture)</Architecture>
Expand Down
78 changes: 78 additions & 0 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/VSTest.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<Project>
<Target Name="RunTests"
Outputs="%(TestToRun.ResultsStdOutPath)">
<PropertyGroup>
<_TestEnvironment>%(TestToRun.EnvironmentDisplay)</_TestEnvironment>
<_TestAssembly>%(TestToRun.Identity)</_TestAssembly>
<_TestRuntime>%(TestToRun.TestRuntime)</_TestRuntime>
<_TestTimeout>%(TestToRun.TestTimeout)</_TestTimeout>
<_TestRunnerAdditionalArguments>%(TestToRun.TestRunnerAdditionalArguments)</_TestRunnerAdditionalArguments>

<!-- Always use net472 for desktop to enable displaying source location from Portable PDBs in stack traces -->
<_TestRunnerTargetFramework>net472</_TestRunnerTargetFramework>
<_TestRunnerTargetFramework Condition="'$(_TestRuntime)' == 'Core'">netcoreapp2.0</_TestRunnerTargetFramework>
<_TestRunnerTargetFramework Condition="%(TestToRun.TargetFramework) == 'netcoreapp1.1' or %(TestToRun.TargetFramework) == 'netcoreapp1.0'">netcoreapp1.0</_TestRunnerTargetFramework>

<_TargetDir>$([System.IO.Path]::GetDirectoryName('$(_TestAssembly)'))\</_TargetDir>

<_TestResultDirectory>$([System.IO.Path]::GetDirectoryName('%(TestToRun.ResultsXmlPath)'))</_TestResultDirectory>
<_TestResultFileName>$([System.IO.Path]::GetFileName('%(TestToRun.ResultsXmlPath)'))</_TestResultFileName>

<_TestRunnerCommand>$(DotNetTool) test $(_TestAssembly) --logger:"console%3Bverbosity=normal" --logger:"trx%3BLogFileName=$(_TestResultFileName)" "--ResultsDirectory:$(_TestResultDirectory)" "--Framework:%(TestToRun.TargetFrameworkIdentifier),Version=%(TestToRun.TargetFrameworkVersion)"</_TestRunnerCommand>
<_TestRunnerCommand Condition="'$(VSTestRunSettingsFile)' != ''">$(_TestRunnerCommand) "--settings:$(VSTestRunSettingsFile)"</_TestRunnerCommand>
<_TestRunnerCommand Condition="'$(_TestRunnerAdditionalArguments)' != ''">$(_TestRunnerCommand) $(_TestRunnerAdditionalArguments)</_TestRunnerCommand>

<!--
Redirect std output of the runner.
-->
<_TestRunnerCommand Condition="'$(TestCaptureOutput)' != 'false'">$(_TestRunnerCommand) > "%(TestToRun.ResultsStdOutPath)" 2>&amp;1</_TestRunnerCommand>
</PropertyGroup>

<ItemGroup>
<_OutputFiles Include="%(TestToRun.ResultsXmlPath)" />
<_OutputFiles Include="%(TestToRun.ResultsHtmlPath)" />
<_OutputFiles Include="%(TestToRun.ResultsStdOutPath)" />
</ItemGroup>

<MakeDir Directories="@(_OutputFiles->'%(RootDir)%(Directory)')"/>
<Delete Files="@(_OutputFiles)" />

<Message Text="Running tests: $(_TestAssembly) [$(_TestEnvironment)]" Importance="high"/>
<Exec Command='$(_TestRunnerCommand)'
LogStandardErrorAsError="false"
WorkingDirectory="$(_TargetDir)"
IgnoreExitCode="true"
Timeout="$(_TestTimeout)"
ContinueOnError="WarnAndContinue">
<Output TaskParameter="ExitCode" PropertyName="_TestErrorCode" />
</Exec>

<!--
Add command line to the log.
-->
<WriteLinesToFile File="%(TestToRun.ResultsStdOutPath)"
Overwrite="false"
Lines=";=== COMMAND LINE ===;$(_TestRunnerCommand)"
Condition="'$(TestCaptureOutput)' != 'false'" />

<!--
Report test status.
-->
<Message Text="Tests succeeded: $(_TestAssembly) [$(_TestEnvironment)]" Condition="'$(_TestErrorCode)' == '0'" Importance="high" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VSTest already does all the test logging.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VSTest output doesn't get placed in the build log.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that's because of the indirection that I mentioned. I don't we should continue doing this with VSTest and just directly invoke it.


<PropertyGroup>
<_ResultsFileToDisplay>%(TestToRun.ResultsHtmlPath)</_ResultsFileToDisplay>
<_ResultsFileToDisplay Condition="!Exists('$(_ResultsFileToDisplay)')">%(TestToRun.ResultsStdOutPath)</_ResultsFileToDisplay>
</PropertyGroup>

<!--
Ideally we would set ContinueOnError="ErrorAndContinue" so that when a test fails in multi-targeted test project
we'll still run tests for all target frameworks. ErrorAndContinue doesn't work well on Linux though: https://github.com/Microsoft/msbuild/issues/3961.
-->
<Error Text="Tests failed: $(_ResultsFileToDisplay) [$(_TestEnvironment)]" Condition="'$(_TestErrorCode)' != '0'" File="VSTest" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VSTest already logs the generated log files like trx and html to stdout. Why are we duplicating that logic?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same reason as above, the output from VSTest is written into a txt file, this shows up in the build log as an error and causes the build to fail when tests fail.


<ItemGroup>
<FileWrites Include="@(_OutputFiles)"/>
</ItemGroup>
</Target>
</Project>
118 changes: 118 additions & 0 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/XUnit/XUnit.Runner.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<Project>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we expect to use this runner type? Is there some benefit to using this rather than vstest?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the current implementation xunit tests default to using this runner. This is the runner it was using before I added vstest as an option.

The xunit console runner works correctly for a few cases where vstest doesn't do the right thing. @tmat can elaborate, but I believe it was tests running on desktop don't get the correct runtime framework version so the compat switches are not set how the test expects.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we defaulting to the thing we don't want people using? Is the plan to change the default later and then remove this implementation, so that vstest is the only option?

Is the desktop scenario something that's important for arcade in master to be supporting?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the desktop scenario is still important because VS is desktop and some of the repos run inside VS.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that imply some repos are staying on netstandard2.0 forever? That's certainly an expensive proposition from a support perspective.

<PropertyGroup>
<XUnitDesktopSettingsFile Condition="'$(XUnitDesktopSettingsFile)' == ''">$(MSBuildThisFileDirectory)xunit.runner.json</XUnitDesktopSettingsFile>
</PropertyGroup>

<!--
Include settings file (xunit.runner.json) if specified.
-->
<ItemGroup>
<None Include="$(XUnitDesktopSettingsFile)"
CopyToOutputDirectory="PreserveNewest"
Visible="false"
Condition="'$(XUnitDesktopSettingsFile)' != '' and '$(TargetFrameworkIdentifier)' == '.NETFramework'" />

<None Include="$(XUnitCoreSettingsFile)"
CopyToOutputDirectory="PreserveNewest"
Visible="false"
Condition="'$(XUnitCoreSettingsFile)' != '' and '$(TargetFrameworkIdentifier)' == '.NETCoreApp'" />
</ItemGroup>

<Target Name="RunTests"
Outputs="%(TestToRun.ResultsStdOutPath)">
<Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Test" />
<PropertyGroup>
<_TestEnvironment>%(TestToRun.EnvironmentDisplay)</_TestEnvironment>
<_TestAssembly>%(TestToRun.Identity)</_TestAssembly>
<_TestRuntime>%(TestToRun.TestRuntime)</_TestRuntime>
<_TestTimeout>%(TestToRun.TestTimeout)</_TestTimeout>
<_TestRunnerAdditionalArguments>%(TestToRun.TestRunnerAdditionalArguments)</_TestRunnerAdditionalArguments>

<!-- Always use net472 for desktop to enable displaying source location from Portable PDBs in stack traces -->
<_TestRunnerTargetFramework>net472</_TestRunnerTargetFramework>
<_TestRunnerTargetFramework Condition="'$(_TestRuntime)' == 'Core'">netcoreapp2.0</_TestRunnerTargetFramework>
<_TestRunnerTargetFramework Condition="%(TestToRun.TargetFramework) == 'netcoreapp1.1' or %(TestToRun.TargetFramework) == 'netcoreapp1.0'">netcoreapp1.0</_TestRunnerTargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(_TestRuntime)' == 'Core'">
<_TargetFileNameNoExt>$([System.IO.Path]::GetFileNameWithoutExtension('$(_TestAssembly)'))</_TargetFileNameNoExt>
<_TargetDir>$([System.IO.Path]::GetDirectoryName('$(_TestAssembly)'))\</_TargetDir>
<_CoreRuntimeConfigPath>$(_TargetDir)$(_TargetFileNameNoExt).runtimeconfig.json</_CoreRuntimeConfigPath>
<_CoreDepsPath>$(_TargetDir)$(_TargetFileNameNoExt).deps.json</_CoreDepsPath>

<_TestRunner Condition="'%(TestToRun.Architecture)'=='x86' And Exists('$(DotNetRoot)x86\dotnet.exe')">$(DotNetRoot)x86\dotnet.exe</_TestRunner>
<_TestRunner Condition="'$(_TestRunner)'==''">$(DotNetTool)</_TestRunner>

<_TestRunnerArgs>exec --depsfile "$(_CoreDepsPath)" --runtimeconfig "$(_CoreRuntimeConfigPath)" $(TestRuntimeAdditionalArguments) "$(NuGetPackageRoot)xunit.runner.console/$(XUnitVersion)/tools/$(_TestRunnerTargetFramework)/xunit.console.dll" "$(_TestAssembly)" -noautoreporters -xml "%(TestToRun.ResultsXmlPath)" -html "%(TestToRun.ResultsHtmlPath)" $(_TestRunnerAdditionalArguments)</_TestRunnerArgs>
</PropertyGroup>

<PropertyGroup Condition="'$(_TestRuntime)' != 'Core'">
<_XUnitConsoleExe>xunit.console.exe</_XUnitConsoleExe>
<_XUnitConsoleExe Condition="'%(TestToRun.Architecture)' == 'x86'">xunit.console.x86.exe</_XUnitConsoleExe>
<_XUnitConsoleExePath>$(NuGetPackageRoot)xunit.runner.console\$(XUnitVersion)\tools\$(_TestRunnerTargetFramework)\$(_XUnitConsoleExe)</_XUnitConsoleExePath>

<_TestRunnerArgs>"$(_TestAssembly)" -noshadow -xml "%(TestToRun.ResultsXmlPath)" -html "%(TestToRun.ResultsHtmlPath)" $(_TestRunnerAdditionalArguments)</_TestRunnerArgs>
<_TestRunnerArgs Condition="'$(_TestRuntime)' == 'Mono'">$(TestRuntimeAdditionalArguments) "$(_XUnitConsoleExePath)" $(_TestRunnerArgs)</_TestRunnerArgs>

<_TestRunner Condition="'$(_TestRuntime)' == 'Mono'">$(MonoTool)</_TestRunner>
<_TestRunner Condition="'$(_TestRuntime)' != 'Mono'">$(_XUnitConsoleExePath)</_TestRunner>
</PropertyGroup>

<PropertyGroup>
<_TestRunnerCommand>"$(_TestRunner)" $(_TestRunnerArgs)</_TestRunnerCommand>

<!--
Redirect std output of the runner.
Note that xUnit outputs failure info to both STDOUT (stack trace, message) and STDERR (failed test name)
-->
<_TestRunnerCommand Condition="'$(TestCaptureOutput)' != 'false'">$(_TestRunnerCommand) > "%(TestToRun.ResultsStdOutPath)" 2>&amp;1</_TestRunnerCommand>
</PropertyGroup>

<ItemGroup>
<_OutputFiles Include="%(TestToRun.ResultsXmlPath)" />
<_OutputFiles Include="%(TestToRun.ResultsHtmlPath)" />
<_OutputFiles Include="%(TestToRun.ResultsStdOutPath)" />
</ItemGroup>

<MakeDir Directories="@(_OutputFiles->'%(RootDir)%(Directory)')"/>
<Delete Files="@(_OutputFiles)" />

<Message Text="Running tests: $(_TestAssembly) [$(_TestEnvironment)]" Importance="high"/>
<Exec Command='$(_TestRunnerCommand)'
LogStandardErrorAsError="false"
WorkingDirectory="$(_TargetDir)"
IgnoreExitCode="true"
Timeout="$(_TestTimeout)"
ContinueOnError="WarnAndContinue">
<Output TaskParameter="ExitCode" PropertyName="_TestErrorCode" />
</Exec>

<!--
Add command line to the log.
-->
<WriteLinesToFile File="%(TestToRun.ResultsStdOutPath)"
Overwrite="false"
Lines=";=== COMMAND LINE ===;$(_TestRunnerCommand)"
Condition="'$(TestCaptureOutput)' != 'false'" />

<!--
Report test status.
-->
<Message Text="Tests succeeded: $(_TestAssembly) [$(_TestEnvironment)]" Condition="'$(_TestErrorCode)' == '0'" Importance="high" />

<PropertyGroup>
<_ResultsFileToDisplay>%(TestToRun.ResultsHtmlPath)</_ResultsFileToDisplay>
<_ResultsFileToDisplay Condition="!Exists('$(_ResultsFileToDisplay)')">%(TestToRun.ResultsStdOutPath)</_ResultsFileToDisplay>
</PropertyGroup>

<!--
Ideally we would set ContinueOnError="ErrorAndContinue" so that when a test fails in multi-targeted test project
we'll still run tests for all target frameworks. ErrorAndContinue doesn't work well on Linux though: https://github.com/Microsoft/msbuild/issues/3961.
-->
<Error Text="Tests failed: $(_ResultsFileToDisplay) [$(_TestEnvironment)]" Condition="'$(_TestErrorCode)' != '0'" File="XUnit" />

<ItemGroup>
<FileWrites Include="@(_OutputFiles)"/>
</ItemGroup>
</Target>
</Project>
10 changes: 0 additions & 10 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/XUnit/XUnit.props

This file was deleted.

Loading