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' ">
77 <CrossgenVar Condition="'$(Crossgen)' == 'true'">set RunCrossGen=true</CrossgenVar>
81 setlocal ENABLEDELAYEDEXPANSION
84 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="'$(TargetsWindows)' != 'true' ">
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="%24HELIX_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>
122 <!-- Crossgen FX assemblies, if running R2R tests.
123 TODO - remove this when we build tests on Linux -->
124 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)overlayDir=%24CORE_ROOT%0a</WrapperShContents>
125 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)if [ ! -f %24overlayDir/crossgenCompleted.mrk ]%3B then%0a</WrapperShContents>
126 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) filesToPrecompile=%24(find -L %24overlayDir -iname \%2A.dll -not -iname \%2A.ni.dll -not -iname \%2A-ms-win-\%2A -type f )%0a</WrapperShContents>
127 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) for fileToPrecompile in %24{filesToPrecompile}%0a</WrapperShContents>
128 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) do%0a</WrapperShContents>
129 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) filename=%24{fileToPrecompile}%0a</WrapperShContents>
130 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) echo Precompiling %24filename%0a</WrapperShContents>
131 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) %24overlayDir/crossgen /Platform_Assemblies_Paths %24overlayDir %24filename 1> %24filename.stdout 2>%24filename.stderr%0a</WrapperShContents>
132 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) exitCode=%24%3F%0a</WrapperShContents>
133 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) if [ %24exitCode != 0 ]%3B then%0a</WrapperShContents>
134 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) if grep -q -e '(COR_E_ASSEMBLYEXPECTED)' %24filename.stderr%3B then%0a</WrapperShContents>
135 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) printf "\n\t%24filename is not a managed assembly.\n\n"%0a</WrapperShContents>
136 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) else%0a</WrapperShContents>
137 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) echo Unable to precompile %24filename.%0a</WrapperShContents>
138 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) fi%0a</WrapperShContents>
139 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) fi%0a</WrapperShContents>
140 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) rm %24filename.stdout%0a</WrapperShContents>
141 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) rm %24filename.stderr%0a</WrapperShContents>
142 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) done%0a</WrapperShContents>
143 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) touch %24overlayDir/crossgenCompleted.mrk%0a</WrapperShContents>
144 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)fi%0a</WrapperShContents>
145 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)%0a</WrapperShContents>
147 <WrapperShContents>$(WrapperShContents)echo BEGIN EXECUTION%0a</WrapperShContents>
148 <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>
149 <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>
150 <WrapperShContents>$(WrapperShContents)ErrorLevel=%24%3F%0a</WrapperShContents>
151 <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
152 <WrapperShContents>$(WrapperShContents)echo Finished running tests. Exit code = %24ErrorLevel%0a</WrapperShContents>
153 <WrapperShContents>$(WrapperShContents)exit %24ErrorLevel%0a</WrapperShContents>
157 <!-- Write the file -->
159 File="$(BuildPath)\runtests.sh"
160 Lines="$(WrapperShContents)"
165 <!-- archive the test binaries along with some supporting files -->
166 <Target Name="ArchiveBuild">
167 <PropertyGroup Condition="'$(ProjectName)'==''">
168 <TestProjectName>$(MSBuildProjectName)</TestProjectName>
171 <!-- the project json and runner script files need to be included in the archive -->
172 <MakeDir Directories="$(BuildArchiveDir)" />
173 <ZipFileCreateFromDirectory SourceDirectory="$(BuildPath)" DestinationArchive="$(BuildArchiveDir)$(ProjectName).zip" OverwriteDestination="true" />
176 <!-- Default target to run - builds executables & archives everything needed for Helix run -->
178 <Target Name="ArchiveAll" >
179 <MSBuild Projects="helixprep.proj"
180 Targets="GenerateWrapperExecutables;ArchiveTests;ArchiveCoreRoot" />