1 <Project ToolsVersion="12.0" DefaultTargets="ArchiveAll" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 <UsingTask TaskName="ZipFileCreateFromDirectory" AssemblyFile="$(ToolsDir)\net46\Microsoft.DotNet.Build.Tasks.dll"/>
5 <Import Project="dir.props" />
6 <Import Project="..\dir.props" />
9 <DiscoveryDirectory>$(TestWorkingDir)</DiscoveryDirectory>
10 <CoreRootDir>$(CORE_ROOT)</CoreRootDir>
11 <CoreRootName>Core_Root_$(RuntimeID)</CoreRootName>
15 <TestCmds Include="$(DiscoveryDirectory)\**\*.cmd" ></TestCmds>
16 <XunitDlls Include="$(DiscoveryDirectory)\**\*.XUnitWrapper.dll" ></XunitDlls>
17 <RequiresSigningFilesToDelete Include="$(DiscoveryDirectory)\**\*.requires_signing" />
20 <!-- Build the platform-specific wrapper to run an individual xunit wrapper -->
22 <Target Name="GenerateWrapperExecutables"
24 Outputs="$(TestWorkingDir)*\runtests.cmd" >
26 <MSBuild Projects="helixprep.proj"
27 Properties="BuildPath=%(XunitDlls.RootDir)%(XunitDlls.Directory);ProjectName=%(XunitDlls.Filename)%(XunitDlls.Extension)"
28 Targets="GenerateWrapperCmd" />
30 <MSBuild Projects="helixprep.proj"
31 Properties="BuildPath=%(XunitDlls.RootDir)%(XunitDlls.Directory);ProjectName=%(XunitDlls.Filename)%(XunitDlls.Extension)"
32 Targets="GenerateWrapperSh" />
35 <!-- Zip each top-level test folder to send to Helix -->
37 <Target Name="ArchiveTests"
39 Outputs="$(TestWorkingDir)archive\**" >
41 <Copy SourceFiles="$(CORE_ROOT)\xunit.console.netcore.exe"
42 DestinationFolder="%(XunitDlls.RootDir)%(XunitDlls.Directory)"
44 <Message Text="Deleting '.requires_signing' files to avoid file name lengths exceeding MAX_PATH" Importance="Low" />
45 <Delete Files="@(RequiresSigningFilesToDelete)" />
46 <MSBuild Projects="helixprep.proj"
47 Properties="BuildPath=%(XunitDlls.RootDir)%(XunitDlls.Directory);ProjectName=%(XunitDlls.Filename);BuildArchiveDir=$(TestWorkingDir)archive\tests\"
48 BuildInParallel="true"
49 Targets="ArchiveBuild" />
52 <!-- Zip Core_Root & Packages payload to send to Helix -->
54 <Target Name="ArchiveCoreRoot"
55 Inputs="$(CoreRootDir)"
56 Outputs="$(TestWorkingDir)archive\Core_Root" >
57 <MSBuild Projects="helixprep.proj"
58 Properties="BuildPath=$(CoreRootDir);ProjectName=$(CoreRootName);BuildArchiveDir=$(TestWorkingDir)archive\Core_Root\"
59 Targets="ArchiveBuild" />
61 <!-- Make dummy packages.zip to upload to Helix -->
63 <DummyDir>$(TestWorkingDir)\archive\dummy</DummyDir>
64 <DummyPackageDir>$(TestWorkingDir)\archive\packages</DummyPackageDir>
67 <MakeDir Directories="$(DummyDir)" />
68 <MakeDir Directories="$(DummyPackageDir)" />
69 <ZipFileCreateFromDirectory SourceDirectory="$(DummyDir)" DestinationArchive="$(DummyPackageDir)\Packages.zip" OverwriteDestination="true" />
72 <!-- Generate wrapper .cmd file for an Xunit wrapper -->
73 <Target Name="GenerateWrapperCmd"
74 Condition="'$(TargetsWindows)' == 'true' ">
80 setlocal ENABLEDELAYEDEXPANSION
83 set CORE_ROOT=%HELIX_CORRELATION_PAYLOAD%
86 ECHO %HELIX_CORRELATION_PAYLOAD%\CoreRun.exe %HELIX_WORKITEM_PAYLOAD%\xunit.console.netcore.exe %HELIX_WORKITEM_PAYLOAD%\$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing
87 %HELIX_CORRELATION_PAYLOAD%\CoreRun.exe %HELIX_WORKITEM_PAYLOAD%\xunit.console.netcore.exe %HELIX_WORKITEM_PAYLOAD%\$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing
89 echo Finished running tests. Exit code = %ERRORLEVEL%
96 <!-- Write the file -->
98 File="$(BuildPath)\runtests.cmd"
99 Lines="$(WrapperCmdContents)"
104 <Target Name="GenerateWrapperSh"
105 Condition="'$(TargetsWindows)' != 'true' ">
107 <!-- Need to force in Unix line endings for Shell script -->
109 <WrapperShContents>#!/bin/sh%0a</WrapperShContents>
110 <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
111 <WrapperShContents>$(WrapperShContents)export CORE_ROOT="$HELIX_CORRELATION_PAYLOAD"%0a</WrapperShContents>
112 <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
113 <WrapperShContents>$(WrapperShContents)for scriptFilePath in %24(find . -type f -iname '%2A.sh' ! -iname "runtests.sh" | sort)%0a</WrapperShContents>
114 <WrapperShContents>$(WrapperShContents)do%0a</WrapperShContents>
115 <WrapperShContents>$(WrapperShContents) perl -pi -e 's/\r\n|\n|\r/\n/g' "%24scriptFilePath"%0a</WrapperShContents>
116 <WrapperShContents>$(WrapperShContents) chmod +x "%24scriptFilePath"%0a</WrapperShContents>
117 <WrapperShContents>$(WrapperShContents)done%0a</WrapperShContents>
118 <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
119 <WrapperShContents>$(WrapperShContents)echo BEGIN EXECUTION%0a</WrapperShContents>
120 <WrapperShContents>$(WrapperShContents)echo "%24{HELIX_CORRELATION_PAYLOAD}/corerun" %24HELIX_WORKITEM_PAYLOAD/xunit.console.netcore.exe %24HELIX_WORKITEM_PAYLOAD/$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing%0a</WrapperShContents>
121 <WrapperShContents>$(WrapperShContents)"%24{HELIX_CORRELATION_PAYLOAD}/corerun" %24HELIX_WORKITEM_PAYLOAD/xunit.console.netcore.exe %24HELIX_WORKITEM_PAYLOAD/$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing%0a</WrapperShContents>
122 <WrapperShContents>$(WrapperShContents)ErrorLevel=%24%3F%0a</WrapperShContents>
123 <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
124 <WrapperShContents>$(WrapperShContents)echo Finished running tests. Exit code = %24ErrorLevel%0a</WrapperShContents>
125 <WrapperShContents>$(WrapperShContents)exit %24ErrorLevel%0a</WrapperShContents>
129 <!-- Write the file -->
131 File="$(BuildPath)\runtests.sh"
132 Lines="$(WrapperShContents)"
137 <!-- archive the test binaries along with some supporting files -->
138 <Target Name="ArchiveBuild">
139 <PropertyGroup Condition="'$(ProjectName)'==''">
140 <TestProjectName>$(MSBuildProjectName)</TestProjectName>
143 <!-- the project json and runner script files need to be included in the archive -->
144 <MakeDir Directories="$(BuildArchiveDir)" />
145 <ZipFileCreateFromDirectory SourceDirectory="$(BuildPath)" DestinationArchive="$(BuildArchiveDir)$(ProjectName).zip" OverwriteDestination="true" />
148 <!-- Default target to run - builds executables & archives everything needed for Helix run -->
150 <Target Name="ArchiveAll" >
151 <MSBuild Projects="helixprep.proj"
152 Targets="GenerateWrapperExecutables;ArchiveTests;ArchiveCoreRoot" />