2 ***********************************************************************************************
3 CLRTest.Execute.targets
5 WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
6 created a backup copy. Incorrect changes to this file will make it
7 impossible to load or build your projects from the command-line or the IDE.
9 This file contains the logic for providing Execution Script generation.
11 WARNING: When setting properties based on their current state (for example:
12 <Foo Condition="'$(Foo)'==''>Bar</Foo>). Be very careful. Another script generation
13 target might be trying to do the same thing. It's better to avoid this by instead setting a new property.
15 Additionally, be careful with itemgroups. Include will propagate outside of the target too!
17 ***********************************************************************************************
19 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22 <BashScriptSnippetGen>$(BashScriptSnippetGen);GetCrossgenBashScript</BashScriptSnippetGen>
23 <BatchScriptSnippetGen>$(BatchScriptSnippetGen);GetCrossgenBatchScript</BatchScriptSnippetGen>
27 This returns the portion of the execution script that generates the required lines to crossgen the test executable.
29 Tests can opt out of ahead-of-time (AOT) compilation from crossgen / crossgen2 by setting this property in their project:
31 <CrossGenTest>false</CrossGenTest>
33 <Target Name="GetCrossgenBashScript">
36 <CrossgenBashScript Condition="'$(CLRTestKind)' == 'BuildAndRun' and '$(CrossGenTest)' != 'false'">
39 if [ ! -z ${RunCrossGen+x} ]%3B then
40 export COMPlus_ZapRequire=$(ZapRequire)
41 export COMPlus_ZapRequireList=$(MSBuildProjectName)
44 echo Inconsistency, IL dir already exists, reinstall tests
51 for file in `find $PWD/IL -name "*.dll"`%3B do
52 filename=`basename $file`
53 outfile="$PWD/$filename"
55 __Command="$CORE_ROOT/crossgen $CrossGenOptions /p $CORE_ROOT%3A$PWD/IL /in $file /out $outfile"
57 echo "Running CrossGen: $__Command"
58 COMPlus_MultiCoreJitProfile= $__Command
60 if [ $__cgExitCode -ne 0 ]
64 echo Crossgen failed for $file with exitcode: $__cgExitCode
71 if [ ! -z ${RunCrossGen2+x} ]%3B then
73 echo Inconsistency, IL dir already exists, reinstall tests
81 for file in `find $CORE_ROOT -maxdepth 1 -name "*.dll" | grep -v ".ni.dll" | grep -v "xunit" `%3B do
82 refs="${refs} -r:$file"
84 for file in `find $PWD/IL -name "*.dll"`%3B do
85 refs="${refs} -r:$file"
88 extraCrossGen2Args="$(CrossGen2TestExtraArguments)"
90 for file in `find $PWD/IL -name "*.dll"`%3B do
91 filename=`basename $file`
92 outfile="$PWD/$filename"
94 __Command="$CORE_ROOT/corerun $CORE_ROOT/crossgen2/crossgen2.dll $CrossGen2Options $extraCrossGen2Args -o%3A$outfile $file ${refs}"
96 echo "Running CrossGen2: $__Command"
97 COMPlus_MultiCoreJitProfile= $__Command
99 if [ $__cg2ExitCode -ne 0 ]
103 echo Crossgen2 failed for $file with exitcode: $__cg2ExitCode
109 </CrossgenBashScript>
111 <CrossgenCleanupBashScript Condition="'$(CLRTestKind)' == 'BuildAndRun' and '$(CrossGenTest)' != 'false'">
113 if [ ! -z ${RunCrossGen+x} ] || [ ! -z ${RunCrossGen2+x} ]%3B then
118 </CrossgenCleanupBashScript>
120 <BashCLRTestPreCommands>$(BashCLRTestPreCommands);$(CrossgenBashScript)</BashCLRTestPreCommands>
121 <BashCLRTestPostCommands>$(BashCLRTestPostCommands);$(CrossgenCleanupBashScript)</BashCLRTestPostCommands>
125 <Target Name="GetCrossgenBatchScript">
127 <CrossgenBatchScript Condition="'$(CLRTestKind)' == 'BuildAndRun' and '$(CrossGenTest)' != 'false'">
131 </CrossgenBatchScript>
133 <CLRTestBatchPreCommands>$(CLRTestBatchPreCommands);$(CrossgenBatchScript)</CLRTestBatchPreCommands>