Skip to content

Instantly share code, notes, and snippets.

@coldacid
Last active March 14, 2016 16:03
Show Gist options
  • Save coldacid/52d645897fedcacb09e3 to your computer and use it in GitHub Desktop.
Save coldacid/52d645897fedcacb09e3 to your computer and use it in GitHub Desktop.
After-solution targets file for xUnit.net
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Test" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">.\</SolutionDir>
</PropertyGroup>
<PropertyGroup>
<xUnitPackageVersion>2.0.0-rc3-build2880</xUnitPackageVersion>
<PackageDir>$(SolutionDir)packages\xunit.runners.$(xUnitPackageVersion)\</PackageDir>
<NUnitXslFile>$(PackageDir)tools\NUnitXml.xslt</NUnitXslFile>
<TestResultFile>$(SolutionDir)TestResult.xml</TestResultFile>
</PropertyGroup>
<PropertyGroup>
<!-- required for solution-level package restore -->
<ProjectDir>$(SolutionDir).nuget</ProjectDir>
<RestorePackages>true</RestorePackages>
<RequireRestoreConsent>false</RequireRestoreConsent>
</PropertyGroup>
<PropertyGroup>
<TestDependsOn>
BeforeTest;
CoreTest;
AfterTest;
</TestDependsOn>
</PropertyGroup>
<ItemGroup>
<None Include="$(SolutionDir).nuget\packages.config" />
</ItemGroup>
<UsingTask AssemblyFile="$(PackageDir)tools\xunit.runner.msbuild.dll" TaskName="Xunit.Runner.MSBuild.xunit" />
<Target Name="Test" AfterTargets="Build;Rebuild" DependsOnTargets="$(TestDependsOn)" />
<Target Name="BeforeTest" />
<Target Name="AfterTest" />
<Target Name="CoreTest" Inputs="@(CollectedBuildOutput)" Outputs="$(TestResultFile)">
<ItemGroup>
<TestAssemblies Include="%(CollectedBuildOutput.FullPath)" Condition="$([System.Text.RegularExpressions.Regex]::IsMatch(%(FullPath), '(?i:\.Tests\.dll)$'))"/>
</ItemGroup>
<PropertyGroup>
<TempFile>$(TestResultFile).tmp</TempFile>
</PropertyGroup>
<xunit Assemblies="@(TestAssemblies)" Xml="$(TempFile)" />
<XslTransformation XmlInputPaths="$(TempFile)" XslInputPath="$(NUnitXslFile)" OutputPaths="$(TestResultFile)" />
<Delete Files="$(TempFile)" ContinueOnError="true" />
</Target>
<Target Name="TestClean" BeforeTargets="Clean;Rebuild">
<Delete Files="$(TestResultFile)" />
</Target>
<Import Project="$(SolutionDir).nuget\NuGet.targets" Condition="Exists('$(SolutionDir).nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="Test">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir).nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir).nuget\NuGet.targets'))" />
<Error Condition="!Exists('$(PackageDir)tools\xunit.runner.msbuild.dll')" Text="$([System.String]::Format('$(ErrorText)', '$(PackageDir)tools\xunit.runner.msbuild.dll'))" />
<Error Condition="!Exists('$(PackageDir)tools\NUnitXml.xslt')" Text="$([System.String]::Format('$(ErrorText)', '$(PackageDir)tools\NUnitXml.xslt'))" />
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment