Make GetCrossgenPackagePaths more specific
authorDavis Goodin <dagood@microsoft.com>
Thu, 9 May 2019 19:35:09 +0000 (14:35 -0500)
committerDavis Goodin <dagood@microsoft.com>
Fri, 10 May 2019 20:01:09 +0000 (15:01 -0500)
Split GetCrossgenPackagePaths to GetCorePackagePaths and GetCrossgenToolPaths.

This fixes failures building for arm/arm64. Generating the package report (new in this PR) calls GetRuntimeFilesToPackage for x64/x86 while TargetArchitecture is arm/arm64. This tries to find a cross-arch crossgen, which doesn't exist with this combination. However, there's no need to find crossgen to generate the report. To fix this, split the target to avoid trying to find a cross-arch crossgen when it isn't needed.

Commit migrated from https://github.com/dotnet/core-setup/commit/388f32f9fafb330473677ef23ca5197ae6fdbb7e

src/installer/pkg/packaging-tools/framework.dependency.targets
src/installer/pkg/projects/netcoreapp/src/netcoreapp.depproj

index b8b03c7..be9a70c 100644 (file)
   <!--
     Get paths from packages that are needed for crossgen. Only relevant for runtime-specific builds.
   -->
-  <Target Name="GetCrossgenPackagePaths"
+  <Target Name="GetCorePackagePaths"
           Condition="'$(NuGetRuntimeIdentifier)' != ''"
           DependsOnTargets="ResolveNuGetPackages">
     <PropertyGroup>
       <_winmdPackageDir>$(PackagesDir)$(MicrosoftTargetingPackPrivateWinRTPackage.ToLowerInvariant())/$(MicrosoftTargetingPackPrivateWinRTPackageVersion)/</_winmdPackageDir>
     </PropertyGroup>
 
+    <PropertyGroup>
+      <_crossDir Condition="'$(TargetArchitecture)' == 'arm' AND '$(OS)' == 'Windows_NT'">/x86_arm</_crossDir>
+      <_crossDir Condition="'$(TargetArchitecture)' == 'arm' AND '$(OS)' != 'Windows_NT'">/x64_arm</_crossDir>
+      <_crossDir Condition="'$(TargetArchitecture)' == 'arm64'">/x64_arm64</_crossDir>
+    </PropertyGroup>
+
+    <ItemGroup>
+      <_requiredProperty Include="_runtimePackageDir;_jitPackageDir;_corefxPackageDir;_winmdPackageDir" />
+    </ItemGroup>
+
+    <Message Text="%(_requiredProperty.Identity): $(%(_requiredProperty.Identity))" />
+    <Error Condition="'$(%(_requiredProperty.Identity))' == ''" Text="Required property %(_requiredProperty.Identity) was not set." />
+    <Error Condition="!Exists('$(%(_requiredProperty.Identity))')" Text="Required property %(_requiredProperty.Identity) with value '$(%(_requiredProperty.Identity))' does not exist." />
+  </Target>
+
+  <Target Name="GetCrossgenToolPaths"
+          Condition="'$(NuGetRuntimeIdentifier)' != ''"
+          DependsOnTargets="GetCorePackagePaths">
     <ItemGroup>
       <!-- Find crossgen tool assets in package cache to allow ExcludeAssets=All. -->
       <_runtimeCLR Include="$(_runtimePackageDir)**/$(LibraryFilePrefix)coreclr$(LibraryFileExtension)" />
       <_windowsWinMD Include="$(_winmdPackageDir)**/Windows.winmd" />
     </ItemGroup>
 
-    <PropertyGroup>
-      <_crossDir Condition="'$(TargetArchitecture)' == 'arm' AND '$(OS)' == 'Windows_NT'">/x86_arm</_crossDir>
-      <_crossDir Condition="'$(TargetArchitecture)' == 'arm' AND '$(OS)' != 'Windows_NT'">/x64_arm</_crossDir>
-      <_crossDir Condition="'$(TargetArchitecture)' == 'arm64'">/x64_arm64</_crossDir>
-    </PropertyGroup>
-
     <PropertyGroup Condition="'@(_runtimeCLR)' != ''">
       <_crossGenPath>$(_runtimePackageDir)tools$(_crossDir)/crossgen$(ApplicationFileExtension)</_crossGenPath>
       <_runtimeDirectory>%(_runtimeCLR.RootDir)%(_runtimeCLR.Directory)</_runtimeDirectory>
     </PropertyGroup>
     
     <ItemGroup>
-      <_requiredProperty Include="_runtimePackageDir;_coreLibDirectory;_crossGenPath;_jitPath;_fxLibDirectory;_windowsWinMDDirectory" />
+      <_requiredProperty Include="_coreLibDirectory;_crossGenPath;_jitPath;_fxLibDirectory;_windowsWinMDDirectory" />
     </ItemGroup>
 
     <Message Text="%(_requiredProperty.Identity): $(%(_requiredProperty.Identity))" />
     <Error Condition="'$(%(_requiredProperty.Identity))' == ''" Text="Required property %(_requiredProperty.Identity) was not set." />
     <Error Condition="!Exists('$(%(_requiredProperty.Identity))')" Text="Required property %(_requiredProperty.Identity) with value '$(%(_requiredProperty.Identity))' does not exist." />
+
+    <ItemGroup>
+      <!--
+        The following path must be passed to crossgen to locate all dependencies. Include it first
+        so in case of conflicts, DLLs are found in the framework being crossgenned.
+      -->
+      <_crossgenPlatformDirectories Include="%(_filesToCrossGen.RootDir)%(_filesToCrossGen.Directory)" />
+      <!-- the following path *must* be passed to crossgen as it has the CoreLib.ni.dll, it will not use the IL copy. -->
+      <_crossgenPlatformDirectories Include="$(_runtimeDirectory)" />
+      <!-- the following need not be passed to crossgen but we do so to be safe. -->
+      <_crossgenPlatformDirectories Include="$(_coreLibDirectory)" />
+      <!-- The following is necessary to crossgen WindowsDesktop. For NETCoreApp it's automatic because we're crossgenning CoreFX bits. -->
+      <_crossgenPlatformDirectories Include="$(_fxLibDirectory)" />
+    </ItemGroup>
+
+    <PropertyGroup>
+      <!-- Use PathSeparator so that we get a ':' on unix and ';' on windows
+           Escape the value so that the ';' doesn't result multiple lines when writing to the RSP file -->
+      <_pathSeparatorEscaped>$([MSBuild]::Escape($([System.IO.Path]::PathSeparator.ToString())))</_pathSeparatorEscaped>
+      <_crossgenPlatformAssemblies>@(_crossgenPlatformDirectories->'%(Identity)', '$(_pathSeparatorEscaped)')</_crossgenPlatformAssemblies>
+    </PropertyGroup>
   </Target>
 
   <!-- Prepares all items for cross-gen and replaces package file items with their cross-gen'ed equivalents -->
   <Target Name="PrepareForCrossGen"
           Condition="'$(NuGetRuntimeIdentifier)' != '' AND '$(DisableCrossgen)' != 'true'"
           DependsOnTargets="
-            GetCrossgenPackagePaths;
+            GetCorePackagePaths;
             GetFilesFromPackages">
     <PropertyGroup>
       <_crossGenIntermediatePath>$(IntermediateOutputPath)/crossgen</_crossGenIntermediatePath>
     </PropertyGroup>
-    <!-- Ensure crossgen is executable.  See https://github.com/NuGet/Home/issues/4424 -->
-    <Exec Command="chmod u+x $(_crossGenPath)"
-          Condition="'$(OSGroup)' != 'Windows_NT'" />
+    
     <ItemGroup>
       <!--
         Skip crossgen for some files, including:
       <_crossGenedFilesToPackage Include="@(_filesToCrossGen->'%(CrossGenedPath)')" />
       <FilesToPackage Include="@(_crossGenedFilesToPackage)" />
     </ItemGroup>
+  </Target>
 
-    <ItemGroup>
-      <!--
-        The following path must be passed to crossgen to locate all dependencies. Include it first
-        so in case of conflicts, DLLs are found in the framework being crossgenned.
-      -->
-      <_crossgenPlatformDirectories Include="%(_filesToCrossGen.RootDir)%(_filesToCrossGen.Directory)" />
-      <!-- the following path *must* be passed to crossgen as it has the CoreLib.ni.dll, it will not use the IL copy. -->
-      <_crossgenPlatformDirectories Include="$(_runtimeDirectory)" />
-      <!-- the following need not be passed to crossgen but we do so to be safe. -->
-      <_crossgenPlatformDirectories Include="$(_coreLibDirectory)" />
-      <!-- The following is necessary to crossgen WindowsDesktop. For NETCoreApp it's automatic because we're crossgenning CoreFX bits. -->
-      <_crossgenPlatformDirectories Include="$(_fxLibDirectory)" />
-    </ItemGroup>
-
-    <PropertyGroup>
-      <!-- Use PathSeparator so that we get a ':' on unix and ';' on windows
-           Escape the value so that the ';' doesn't result multiple lines when writing to the RSP file -->
-      <_pathSeparatorEscaped>$([MSBuild]::Escape($([System.IO.Path]::PathSeparator.ToString())))</_pathSeparatorEscaped>
-      <_crossgenPlatformAssemblies>@(_crossgenPlatformDirectories->'%(Identity)', '$(_pathSeparatorEscaped)')</_crossgenPlatformAssemblies>
-    </PropertyGroup>
+  <!-- Ensure crossgen is executable. See https://github.com/NuGet/Home/issues/4424 -->
+  <Target Name="EnsureCrossGenIsExecutable"
+          Condition="'$(OSGroup)' != 'Windows_NT'"
+          DependsOnTargets="GetCrossgenToolPaths">
+    <Exec
+      Command="chmod u+x $(_crossGenPath)"
+      Condition="'$(OSGroup)' != 'Windows_NT' AND Exists('$(_crossGenPath)')" />
   </Target>
 
   <Target Name="CrossGen"
           BeforeTargets="Build"
-          DependsOnTargets="CreateCrossGenImages;CreateCrossGenSymbols" />
+          DependsOnTargets="
+            GetCrossgenToolPaths;
+            EnsureCrossGenIsExecutable;
+            CreateCrossGenImages;
+            CreateCrossGenSymbols" />
 
   <Target Name="CreateCrossGenImages"
           DependsOnTargets="PrepareForCrossGen"
index 00df5c1..86646eb 100644 (file)
@@ -27,7 +27,7 @@
        only relevant for runtime-specific builds -->
   <Target Name="GetPackagePaths"
           Condition="'$(NuGetRuntimeIdentifier)' != ''"
-          DependsOnTargets="GetCrossgenPackagePaths" />
+          DependsOnTargets="GetCorePackagePaths" />
 
   <Target Name="GetDependencyVersionFiles" DependsOnTargets="GetPackagePaths;ResolveNuGetPackages">
     <ItemGroup>
@@ -55,7 +55,7 @@
   <!-- Fetches all the runtime items from the packages that we want to redist -->
   <Target Name="GetRuntimeFilesFromPackages"
           BeforeTargets="GetRuntimeFilesToPackage"
-          DependsOnTargets="GetCrossgenPackagePaths">
+          DependsOnTargets="GetCorePackagePaths">
     <ItemGroup Condition="'$(NuGetRuntimeIdentifier)' != ''">
       <_ToolsToPackage Include="$(_runtimePackageDir)tools/**/*.*"/>
       <FilesToPackage Include="@(_ToolsToPackage)">