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 Condition="'$(RuntimeID)' == '' ">$(CORE_ROOT)</CoreRootDir>
11 <CoreRootDir Condition="'$(RuntimeID)' != '' ">$(CORE_OVERLAY)</CoreRootDir>
12 <CoreRootName Condition="'$(RuntimeID)' == '' ">Core_Root_Windows_NT-$(__BuildArch)</CoreRootName>
13 <CoreRootName Condition="'$(RuntimeID)' != '' ">Core_Root_$(RuntimeID)</CoreRootName>
17 <TestCmds Include="$(DiscoveryDirectory)\**\*.cmd" ></TestCmds>
18 <XunitDlls Include="$(DiscoveryDirectory)\**\*.XUnitWrapper.dll" ></XunitDlls>
19 <RequiresSigningFilesToDelete Include="$(DiscoveryDirectory)\**\*.requires_signing" />
22 <!-- Build the platform-specific wrapper to run an individual xunit wrapper -->
24 <Target Name="GenerateWrapperExecutables"
26 Outputs="$(TestWorkingDir)*\runtests.cmd" >
28 <MSBuild Projects="helixprep.proj"
29 Properties="BuildPath=%(XunitDlls.RootDir)%(XunitDlls.Directory);ProjectName=%(XunitDlls.Filename)%(XunitDlls.Extension)"
30 Targets="GenerateWrapperCmd" />
32 <MSBuild Projects="helixprep.proj"
33 Properties="BuildPath=%(XunitDlls.RootDir)%(XunitDlls.Directory);ProjectName=%(XunitDlls.Filename)%(XunitDlls.Extension)"
34 Targets="GenerateWrapperSh" />
37 <!-- Zip each top-level test folder to send to Helix -->
39 <Target Name="ArchiveTests"
41 Outputs="$(TestWorkingDir)archive\**" >
43 <Copy SourceFiles="$(CORE_ROOT)\xunit.console.netcore.exe"
44 DestinationFolder="%(XunitDlls.RootDir)%(XunitDlls.Directory)"
46 <Message Text="Deleting '.requires_signing' files to avoid file name lengths exceeding MAX_PATH" Importance="Low" />
47 <Delete Files="@(RequiresSigningFilesToDelete)" />
48 <MSBuild Projects="helixprep.proj"
49 Properties="BuildPath=%(XunitDlls.RootDir)%(XunitDlls.Directory);ProjectName=%(XunitDlls.Filename);BuildArchiveDir=$(TestWorkingDir)archive\tests\"
50 BuildInParallel="true"
51 Targets="ArchiveBuild" />
54 <!-- Zip Core_Root & Packages payload to send to Helix -->
56 <Target Name="ArchiveCoreRoot"
57 Inputs="$(CoreRootDir)"
58 Outputs="$(TestWorkingDir)archive\Core_Root" >
59 <MSBuild Projects="helixprep.proj"
60 Properties="BuildPath=$(CoreRootDir);ProjectName=$(CoreRootName);BuildArchiveDir=$(TestWorkingDir)archive\Core_Root\"
61 Targets="ArchiveBuild" />
63 <!-- Make dummy packages.zip to upload to Helix -->
65 <DummyDir>$(TestWorkingDir)\archive\dummy</DummyDir>
66 <DummyPackageDir>$(TestWorkingDir)\archive\packages</DummyPackageDir>
69 <MakeDir Directories="$(DummyDir)" />
70 <MakeDir Directories="$(DummyPackageDir)" />
71 <ZipFileCreateFromDirectory SourceDirectory="$(DummyDir)" DestinationArchive="$(DummyPackageDir)\Packages.zip" OverwriteDestination="true" />
74 <!-- Generate wrapper .cmd file for an Xunit wrapper -->
75 <Target Name="GenerateWrapperCmd"
76 Condition="'$(RuntimeID)' == '' ">
82 setlocal ENABLEDELAYEDEXPANSION
85 set CORE_ROOT=%HELIX_CORRELATION_PAYLOAD%
88 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
89 %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
91 echo Finished running tests. Exit code = %ERRORLEVEL%
98 <!-- Write the file -->
100 File="$(BuildPath)\runtests.cmd"
101 Lines="$(WrapperCmdContents)"
106 <Target Name="GenerateWrapperSh"
107 Condition="'$(RuntimeID)' != '' ">
109 <!-- Need to force in Unix line endings for Shell script -->
111 <WrapperShContents>#!/bin/sh%0a</WrapperShContents>
112 <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
113 <WrapperShContents>$(WrapperShContents)export CORE_ROOT="$HELIX_CORRELATION_PAYLOAD"%0a</WrapperShContents>
114 <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
115 <WrapperShContents>$(WrapperShContents)for scriptFilePath in %24(find . -type f -iname '%2A.sh' ! -iname "runtests.sh" | sort)%0a</WrapperShContents>
116 <WrapperShContents>$(WrapperShContents)do%0a</WrapperShContents>
117 <WrapperShContents>$(WrapperShContents) perl -pi -e 's/\r\n|\n|\r/\n/g' "%24scriptFilePath"%0a</WrapperShContents>
118 <WrapperShContents>$(WrapperShContents) chmod +x "%24scriptFilePath"%0a</WrapperShContents>
119 <WrapperShContents>$(WrapperShContents)done%0a</WrapperShContents>
120 <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
121 <WrapperShContents>$(WrapperShContents)echo BEGIN EXECUTION%0a</WrapperShContents>
122 <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>
123 <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>
124 <WrapperShContents>$(WrapperShContents)ErrorLevel=%24%3F%0a</WrapperShContents>
125 <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
126 <WrapperShContents>$(WrapperShContents)echo Finished running tests. Exit code = %24ErrorLevel%0a</WrapperShContents>
127 <WrapperShContents>$(WrapperShContents)exit %24ErrorLevel%0a</WrapperShContents>
131 <!-- Write the file -->
133 File="$(BuildPath)\runtests.sh"
134 Lines="$(WrapperShContents)"
139 <!-- archive the test binaries along with some supporting files -->
140 <Target Name="ArchiveBuild">
141 <PropertyGroup Condition="'$(ProjectName)'==''">
142 <TestProjectName>$(MSBuildProjectName)</TestProjectName>
145 <!-- the project json and runner script files need to be included in the archive -->
146 <MakeDir Directories="$(BuildArchiveDir)" />
147 <ZipFileCreateFromDirectory SourceDirectory="$(BuildPath)" DestinationArchive="$(BuildArchiveDir)$(ProjectName).zip" OverwriteDestination="true" />
150 <!-- Default target to run - builds executables & archives everything needed for Helix run -->
152 <Target Name="ArchiveAll" >
153 <MSBuild Projects="helixprep.proj"
154 Targets="GenerateWrapperExecutables;ArchiveTests;ArchiveCoreRoot" />