| 
70 | 70 |     <DefineConstants>$(DefineConstants);SINGLE_FILE_TEST_RUNNER</DefineConstants>  | 
71 | 71 |   </PropertyGroup>  | 
72 | 72 | 
 
  | 
 | 73 | +  <PropertyGroup Condition="'$(TestReadyToRun)' == 'true'">  | 
 | 74 | +    <DefineConstants>$(DefineConstants);TEST_READY_TO_RUN_COMPILED</DefineConstants>  | 
 | 75 | +  </PropertyGroup>  | 
 | 76 | + | 
73 | 77 |   <Import Project="$(CoreCLRBuildIntegrationDir)Microsoft.DotNet.ILCompiler.SingleEntry.targets" Condition="'$(TestNativeAot)' == 'true'" />  | 
74 | 78 | 
 
  | 
75 | 79 |   <ItemGroup Condition="'$(TestNativeAot)' == 'true'">  | 
 | 
106 | 110 |     </ItemGroup>  | 
107 | 111 |   </Target>  | 
108 | 112 | 
 
  | 
 | 113 | +  <!--  | 
 | 114 | +      For TestReadyToRun, we need the whole framework to be R2R-compiled besides  | 
 | 115 | +      the actual test assembly. However, this is a very lengthy process and it's  | 
 | 116 | +      unnecessary in this case because we already have an R2R-compiled framework.  | 
 | 117 | +      So, we have to tell the build that we already have these binaries so that it  | 
 | 118 | +      doesn't build them again for each test.  | 
 | 119 | +  -->  | 
 | 120 | +  <Target Name="ExcludeExistingR2RBinaries"  | 
 | 121 | +          Condition="'$(TestReadyToRun)' == 'true'"  | 
 | 122 | +          BeforeTargets="_PrepareForReadyToRunCompilation">  | 
 | 123 | +    <PropertyGroup>  | 
 | 124 | +      <ArtifactsNetCoreAppBundlePath>$(ArtifactsObjDir)Microsoft.NETCore.App.Bundle/</ArtifactsNetCoreAppBundlePath>  | 
 | 125 | +      <ArtifactsNetCoreAppBundlePath>$(ArtifactsNetCoreAppBundlePath)$(Configuration)/$(NetCoreAppCurrent)/$(OutputRID)/output/</ArtifactsNetCoreAppBundlePath>  | 
 | 126 | +      <ArtifactsNetCoreAppBundlePath>$(ArtifactsNetCoreAppBundlePath)shared/$(MicrosoftNetCoreAppFrameworkName)/$(PackageVersion)/</ArtifactsNetCoreAppBundlePath>  | 
 | 127 | +    </PropertyGroup>  | 
 | 128 | + | 
 | 129 | +    <ItemGroup>  | 
 | 130 | +      <_BundleAssembliesToCopy Include="$(ArtifactsNetCoreAppBundlePath)*.dll" />  | 
 | 131 | +      <ResolvedFileToPublish Remove="@(_BundleAssembliesToCopy)" MatchOnMetadata="Filename" />  | 
 | 132 | +    </ItemGroup>  | 
 | 133 | +  </Target>  | 
 | 134 | + | 
 | 135 | +  <!--  | 
 | 136 | +      For TestReadyToRun, each crossgen'd assembly needs to reference the whole  | 
 | 137 | +      framework. For this, it looks at the contents of the same list that contains  | 
 | 138 | +      all the assemblies we're going to R2R-compile. However, since we removed those  | 
 | 139 | +      belonging to the framework we have ready to use in the previous target, then  | 
 | 140 | +      the references list generated in _PrepareForReadyToRunCompilation is incomplete.  | 
 | 141 | +      So, we add those missing assemblies only to the references list in this target.  | 
 | 142 | +  -->  | 
 | 143 | +  <Target Name="AddExistingR2RBinariesReferencesForCrossgen2"  | 
 | 144 | +          Condition="'$(TestReadyToRun)' == 'true'"  | 
 | 145 | +          AfterTargets="_PrepareForReadyToRunCompilation">  | 
 | 146 | +    <ItemGroup>  | 
 | 147 | +      <_ReadyToRunAssembliesToReference Include="@(_BundleAssembliesToCopy)" />  | 
 | 148 | +    </ItemGroup>  | 
 | 149 | +  </Target>  | 
 | 150 | + | 
 | 151 | +  <!--  | 
 | 152 | +      For TestReadyToRun, debugging binaries bloat the test sizes way too much and  | 
 | 153 | +      makes the Helix machines run out of disk. Since we don't need them for the  | 
 | 154 | +      TestReadyToRun test runs, we remove them from the list that is later on copied  | 
 | 155 | +      to the final location.  | 
 | 156 | +  -->  | 
 | 157 | +  <Target Name="RemoveDbgBinsFromTestR2ROutput"  | 
 | 158 | +          Condition="'$(TestReadyToRun)' == 'true'"  | 
 | 159 | +          BeforeTargets="_CopyFilesMarkedCopyLocal">  | 
 | 160 | +    <ItemGroup>  | 
 | 161 | +      <ReferenceCopyLocalPaths  | 
 | 162 | +          Remove="@(ReferenceCopyLocalPaths->WithMetadataValue('Extension', '.dbg'))" />  | 
 | 163 | +    </ItemGroup>  | 
 | 164 | +  </Target>  | 
 | 165 | + | 
 | 166 | +  <!--  | 
 | 167 | +      Very similarly to the previous target, we need to get rid of the debugging  | 
 | 168 | +      binaries from the publishing directory as well.  | 
 | 169 | +  -->  | 
 | 170 | +  <Target Name="RemoveDbgBinsFromTestR2RPublish"  | 
 | 171 | +          Condition="'$(TestReadyToRun)' == 'true'"  | 
 | 172 | +          BeforeTargets="_CopyResolvedFilesToPublishPreserveNewest">  | 
 | 173 | +    <ItemGroup>  | 
 | 174 | +      <_ResolvedFileToPublishPreserveNewest  | 
 | 175 | +          Remove="@(_ResolvedFileToPublishPreserveNewest->WithMetadataValue('Extension', '.dbg'))" />  | 
 | 176 | +    </ItemGroup>  | 
 | 177 | +  </Target>  | 
 | 178 | + | 
 | 179 | +  <!--  | 
 | 180 | +      As explained in Target 'ExcludeExistingR2RBinaries' up above, for TestReadyToRun  | 
 | 181 | +      we need the fully R2R-compiled framework, but we already have it elsewhere. So,  | 
 | 182 | +      once the test's specific stuff is constructed, we copy the R2R-compiled framework  | 
 | 183 | +      to the test's self-contained directory so the test can use it when called.  | 
 | 184 | +  -->  | 
 | 185 | +  <Target Name="CopyExistingR2RBinaries"  | 
 | 186 | +          Condition="'$(TestReadyToRun)' == 'true'"  | 
 | 187 | +          AfterTargets="_CopyResolvedFilesToPublishAlways">  | 
 | 188 | + | 
 | 189 | +    <Copy SourceFiles="@(_BundleAssembliesToCopy)"  | 
 | 190 | +          DestinationFolder="$(PublishDir)"  | 
 | 191 | +          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"  | 
 | 192 | +          Retries="$(CopyRetryCount)"  | 
 | 193 | +          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"  | 
 | 194 | +          UseHardlinksIfPossible="$(CreateHardLinksForPublishFilesIfPossible)"  | 
 | 195 | +          UseSymboliclinksIfPossible="$(CreateSymbolicLinksForPublishFilesIfPossible)" />  | 
 | 196 | + | 
 | 197 | +  </Target>  | 
 | 198 | + | 
 | 199 | +  <!--  | 
 | 200 | +      There are a few tests that need a 'live-ref-pack', which is missing from the  | 
 | 201 | +      publish directory in TestReadyToRun builds. This target copies it there.  | 
 | 202 | +  -->  | 
 | 203 | +  <Target Name="CopyLiveRefPackIfPresent"  | 
 | 204 | +          Condition="'$(TestReadyToRun)' == 'true'"  | 
 | 205 | +          AfterTargets="CopyExistingR2RBinaries">  | 
 | 206 | + | 
 | 207 | +    <ItemGroup>  | 
 | 208 | +      <OutDirLiveRefPackFiles Include="$(OutDir)live-ref-pack/*" />  | 
 | 209 | +    </ItemGroup>  | 
 | 210 | + | 
 | 211 | +    <Copy SourceFiles="@(OutDirLiveRefPackFiles)"  | 
 | 212 | +          DestinationFolder="$(PublishDir)live-ref-pack"  | 
 | 213 | +          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"  | 
 | 214 | +          Retries="$(CopyRetryCount)"  | 
 | 215 | +          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"  | 
 | 216 | +          UseHardlinksIfPossible="$(CreateHardLinksForPublishFilesIfPossible)"  | 
 | 217 | +          UseSymboliclinksIfPossible="$(CreateSymbolicLinksForPublishFilesIfPossible)" />  | 
 | 218 | + | 
 | 219 | +  </Target>  | 
 | 220 | + | 
109 | 221 |   <Target Name="__UpdateExcludedAssembliesFromSingleFile"  | 
110 | 222 |           Inputs="ExcludeFromSingleFile"  | 
111 | 223 |           Outputs="ResolvedFileToPublish"  | 
 | 
0 commit comments