1 <?xml version="1.0" encoding="utf-8"?>
2 <Project ToolsVersion="12.0" DefaultTargets="ArchiveAll" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
4 <UsingTask TaskName="ZipFileCreateFromDirectory" AssemblyFile="$(ToolsDir)\net46\Microsoft.DotNet.Build.Tasks.dll"/>
6 <Import Project="dir.props" />
7 <Import Project="..\dir.props" />
10 <DiscoveryDirectory>$(TestWorkingDir)</DiscoveryDirectory>
11 <CoreRootDir>$(CORE_ROOT)</CoreRootDir>
12 <CoreRootName>Core_Root_$(RuntimeID)</CoreRootName>
16 <TestCmds Include="$(DiscoveryDirectory)\**\*.cmd" ></TestCmds>
17 <XunitDlls Include="$(DiscoveryDirectory)\**\*.XUnitWrapper.dll" ></XunitDlls>
18 <RequiresSigningFilesToDelete Include="$(DiscoveryDirectory)\**\*.requires_signing" />
21 <!-- Build the platform-specific wrapper to run an individual xunit wrapper -->
23 <Target Name="GenerateWrapperExecutables"
25 Outputs="$(TestWorkingDir)*\runtests.cmd" >
27 <MSBuild Projects="helixprep.proj"
28 Properties="BuildPath=%(XunitDlls.RootDir)%(XunitDlls.Directory);ProjectName=%(XunitDlls.Filename)%(XunitDlls.Extension)"
29 Targets="GenerateWrapperCmd" />
31 <MSBuild Projects="helixprep.proj"
32 Properties="BuildPath=%(XunitDlls.RootDir)%(XunitDlls.Directory);ProjectName=%(XunitDlls.Filename)%(XunitDlls.Extension)"
33 Targets="GenerateWrapperSh" />
36 <!-- Zip each top-level test folder to send to Helix -->
38 <Target Name="ArchiveTests"
40 Outputs="$(TestWorkingDir)archive\**" >
42 <Copy SourceFiles="$(CORE_ROOT)\xunit.console.netcore.exe"
43 DestinationFolder="%(XunitDlls.RootDir)%(XunitDlls.Directory)"
45 <Message Text="Deleting '.requires_signing' files to avoid file name lengths exceeding MAX_PATH" Importance="Low" />
46 <Delete Files="@(RequiresSigningFilesToDelete)" />
47 <MSBuild Projects="helixprep.proj"
48 Properties="BuildPath=%(XunitDlls.RootDir)%(XunitDlls.Directory);ProjectName=%(XunitDlls.Filename);BuildArchiveDir=$(TestWorkingDir)archive\tests\"
49 BuildInParallel="true"
50 Targets="ArchiveBuild" />
53 <!-- Zip Core_Root & Packages payload to send to Helix -->
55 <Target Name="ArchiveCoreRoot"
56 Inputs="$(CoreRootDir)"
57 Outputs="$(TestWorkingDir)archive\Core_Root" >
58 <MSBuild Projects="helixprep.proj"
59 Properties="BuildPath=$(CoreRootDir);ProjectName=$(CoreRootName);BuildArchiveDir=$(TestWorkingDir)archive\Core_Root\"
60 Targets="ArchiveBuild" />
62 <!-- Make dummy packages.zip to upload to Helix -->
64 <DummyDir>$(TestWorkingDir)\archive\dummy</DummyDir>
65 <DummyPackageDir>$(TestWorkingDir)\archive\packages</DummyPackageDir>
68 <MakeDir Directories="$(DummyDir)" />
69 <MakeDir Directories="$(DummyPackageDir)" />
70 <ZipFileCreateFromDirectory SourceDirectory="$(DummyDir)" DestinationArchive="$(DummyPackageDir)\Packages.zip" OverwriteDestination="true" />
73 <!-- Generate wrapper .cmd file for an Xunit wrapper -->
74 <Target Name="GenerateWrapperCmd"
75 Condition="'$(TargetsWindows)' == 'true' ">
78 <CmdCrossgenVar Condition="'$(Crossgen)' == 'true'">set RunCrossGen=true</CmdCrossgenVar>
82 setlocal ENABLEDELAYEDEXPANSION
85 set CORE_ROOT=%HELIX_CORRELATION_PAYLOAD%
89 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
90 %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
92 echo Finished running tests. Exit code = %ERRORLEVEL%
99 <!-- Write the file -->
101 File="$(BuildPath)\runtests.cmd"
102 Lines="$(WrapperCmdContents)"
107 <Target Name="GenerateWrapperSh"
108 Condition="'$(TargetsWindows)' != 'true' ">
110 <!-- Need to force in Unix line endings for Shell script -->
112 <WrapperShContents>#!/bin/sh%0a</WrapperShContents>
113 <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
114 <WrapperShContents>$(WrapperShContents)export CORE_ROOT="%24HELIX_CORRELATION_PAYLOAD"%0a</WrapperShContents>
115 <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
116 <WrapperShContents>$(WrapperShContents)for scriptFilePath in %24(find . -type f -iname '%2A.sh' ! -iname "runtests.sh" | sort)%0a</WrapperShContents>
117 <WrapperShContents>$(WrapperShContents)do%0a</WrapperShContents>
118 <WrapperShContents>$(WrapperShContents) perl -pi -e 's/\r\n|\n|\r/\n/g' "%24scriptFilePath"%0a</WrapperShContents>
119 <WrapperShContents>$(WrapperShContents) chmod +x "%24scriptFilePath"%0a</WrapperShContents>
120 <WrapperShContents>$(WrapperShContents)done%0a</WrapperShContents>
121 <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
123 <!-- Crossgen FX assemblies, if running R2R tests.
124 TODO - remove this when we build tests on Linux -->
125 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)export RunCrossGen=true%0a</WrapperShContents>
126 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)overlayDir=%24CORE_ROOT%0a</WrapperShContents>
127 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)if [ ! -f %24overlayDir/crossgenCompleted.mrk ]%3B then%0a</WrapperShContents>
128 <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>
129 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) for fileToPrecompile in %24{filesToPrecompile}%0a</WrapperShContents>
130 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) do%0a</WrapperShContents>
131 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) filename=%24{fileToPrecompile}%0a</WrapperShContents>
132 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) echo Precompiling %24filename%0a</WrapperShContents>
133 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) %24overlayDir/crossgen /Platform_Assemblies_Paths %24overlayDir /in %24filename /out %24overlayDir/temp.ni.dll 1> %24filename.stdout 2>%24filename.stderr%0a</WrapperShContents>
134 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) exitCode=%24%3F%0a</WrapperShContents>
135 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) if [ %24exitCode != 0 ]%3B then%0a</WrapperShContents>
136 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) if grep -q -e '(COR_E_ASSEMBLYEXPECTED)' %24filename.stderr%3B then%0a</WrapperShContents>
137 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) printf "\n\t%24filename is not a managed assembly.\n\n"%0a</WrapperShContents>
138 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) else%0a</WrapperShContents>
139 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) echo Unable to precompile %24filename.%0a</WrapperShContents>
140 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) fi%0a</WrapperShContents>
141 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) else%0a</WrapperShContents>
142 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) rm %24filename%0a</WrapperShContents>
143 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) mv %24overlayDir/temp.ni.dll %24filename%0a</WrapperShContents>
144 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) fi%0a</WrapperShContents>
145 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) rm %24filename.stdout%0a</WrapperShContents>
146 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) rm %24filename.stderr%0a</WrapperShContents>
147 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) done%0a</WrapperShContents>
148 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents) touch %24overlayDir/crossgenCompleted.mrk%0a</WrapperShContents>
149 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)fi%0a</WrapperShContents>
150 <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)%0a</WrapperShContents>
152 <WrapperShContents>$(WrapperShContents)echo BEGIN EXECUTION%0a</WrapperShContents>
153 <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>
154 <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>
155 <WrapperShContents>$(WrapperShContents)ErrorLevel=%24%3F%0a</WrapperShContents>
156 <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
157 <WrapperShContents>$(WrapperShContents)echo Finished running tests. Exit code = %24ErrorLevel%0a</WrapperShContents>
158 <WrapperShContents>$(WrapperShContents)exit %24ErrorLevel%0a</WrapperShContents>
162 <!-- Write the file -->
164 File="$(BuildPath)\runtests.sh"
165 Lines="$(WrapperShContents)"
170 <!-- archive the test binaries along with some supporting files -->
171 <Target Name="ArchiveBuild">
172 <PropertyGroup Condition="'$(ProjectName)'==''">
173 <TestProjectName>$(MSBuildProjectName)</TestProjectName>
176 <!-- the project json and runner script files need to be included in the archive -->
177 <MakeDir Directories="$(BuildArchiveDir)" />
178 <ZipFileCreateFromDirectory SourceDirectory="$(BuildPath)" DestinationArchive="$(BuildArchiveDir)$(ProjectName).zip" OverwriteDestination="true" />
181 <!-- Default target to run - builds executables & archives everything needed for Helix run -->
183 <Target Name="ArchiveAll" >
184 <MSBuild Projects="helixprep.proj"
185 Targets="GenerateWrapperExecutables;ArchiveTests;ArchiveCoreRoot" />