Skip to content

Commit

Permalink
Use generated runtime.json when building shared framework packages. (#…
Browse files Browse the repository at this point in the history
…76068)

* Use generated runtime.json when building shared framework packages.

* Don't UpdateRuntimeJson on Build.

* PR feedback.

* Update Microsoft.NETCore.Platforms.csproj

Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>
  • Loading branch information
tmds and ViktorHofer authored Sep 27, 2022
1 parent 0075639 commit cd2f0ff
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
1 change: 0 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@
<PackageProjectUrl>https://dot.net</PackageProjectUrl>
<Owners>microsoft,dotnetframework</Owners>
<IncludeSymbols>true</IncludeSymbols>
<RuntimeIdGraphDefinitionFile>$([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'Microsoft.NETCore.Platforms', 'src', 'runtime.json'))</RuntimeIdGraphDefinitionFile>
<LicenseFile>$(MSBuildThisFileDirectory)LICENSE.TXT</LicenseFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
Expand Down
4 changes: 3 additions & 1 deletion eng/liveBuilds.targets
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@
ResolveLibrariesRuntimeFilesFromLocalBuild" />

<PropertyGroup>
<BundledRuntimeIdentifierGraphFile>$(RuntimeIdGraphDefinitionFile)</BundledRuntimeIdentifierGraphFile>
<!-- Keep in sync with outputs defined in Microsoft.NETCore.Platforms.csproj. -->
<BundledRuntimeIdentifierGraphFile>$([MSBuild]::NormalizePath('$(ArtifactsBinDir)', 'Microsoft.NETCore.Platforms', 'runtime.json'))</BundledRuntimeIdentifierGraphFile>
<BundledRuntimeIdentifierGraphFile Condition="!Exists('$(BundledRuntimeIdentifierGraphFile)')">$([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'Microsoft.NETCore.Platforms', 'src', 'runtime.json'))</BundledRuntimeIdentifierGraphFile>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<AvoidRestoreCycleOnSelfReference>true</AvoidRestoreCycleOnSelfReference>
<!-- TODO: Remove with AvoidRestoreCycleOnSelfReference hack. -->
<PackageValidationBaselineName>$(MSBuildProjectName)</PackageValidationBaselineName>
<BeforePack>GenerateRuntimeJson;UpdateRuntimeJson;$(BeforePack)</BeforePack>

This comment has been minimized.

Copy link
@ViktorHofer

ViktorHofer Feb 15, 2023

Author Member

@tmds because of this change, the UpdateRuntimeJson target doesn't run anymore. Was that intentional? Asking as #82125 was just filed and this is likely the suspect.

This comment has been minimized.

Copy link
@tmds

tmds Feb 15, 2023

Author Member

Yes, this is the cause.

It was intentional to run GenerateRuntimeJson with AfterTargets="Build".
But unintentional to no longer run UpdateRuntimeJson when packing.


<_generateRuntimeGraphTargetFramework Condition="'$(MSBuildRuntimeType)' == 'core'">$(NetCoreAppToolCurrent)</_generateRuntimeGraphTargetFramework>
<_generateRuntimeGraphTargetFramework Condition="'$(MSBuildRuntimeType)' != 'core'">net472</_generateRuntimeGraphTargetFramework>
Expand All @@ -44,7 +43,7 @@

<ItemGroup>
<Content Condition="'$(AdditionalRuntimeIdentifiers)' == ''" Include="runtime.json" PackagePath="/" />
<Content Condition="'$(AdditionalRuntimeIdentifiers)' != ''" Include="$(IntermediateOutputPath)runtime.json" PackagePath="/" />
<Content Condition="'$(AdditionalRuntimeIdentifiers)' != ''" Include="$(BaseOutputPath)runtime.json" PackagePath="/" />
<Content Include="$(PlaceholderFile)" PackagePath="lib/netstandard1.0" />
</ItemGroup>

Expand All @@ -58,12 +57,12 @@

<UsingTask TaskName="GenerateRuntimeGraph" AssemblyFile="$(_generateRuntimeGraphTask)"/>

<Target Name="GenerateRuntimeJson" Condition="'$(AdditionalRuntimeIdentifiers)' != ''">
<Target Name="GenerateRuntimeJson" AfterTargets="Build" Condition="'$(AdditionalRuntimeIdentifiers)' != ''">
<MakeDir Directories="$(IntermediateOutputPath)" />
<GenerateRuntimeGraph RuntimeGroups="@(RuntimeGroupWithQualifiers)"
AdditionalRuntimeIdentifiers="$(AdditionalRuntimeIdentifiers)"
AdditionalRuntimeIdentifierParent="$(AdditionalRuntimeIdentifierParent)"
RuntimeJson="$(IntermediateOutputPath)runtime.json"
RuntimeJson="$(BaseOutputPath)runtime.json"
UpdateRuntimeFiles="True" />
</Target>

Expand Down
3 changes: 1 addition & 2 deletions src/libraries/oob-all.proj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
<!-- Build these packages in the allconfigurations leg only. -->
<ProjectReference Remove="Microsoft.Internal.Runtime.AspNetCore.Transport\src\Microsoft.Internal.Runtime.AspNetCore.Transport.proj;
Microsoft.Internal.Runtime.WindowsDesktop.Transport\src\Microsoft.Internal.Runtime.WindowsDesktop.Transport.proj;
Microsoft.Windows.Compatibility\src\Microsoft.Windows.Compatibility.csproj;
Microsoft.NETCore.Platforms\src\Microsoft.NETCore.Platforms.csproj"
Microsoft.Windows.Compatibility\src\Microsoft.Windows.Compatibility.csproj"
Condition="'$(BuildAllConfigurations)' != 'true'" />

<!-- Skip these projects during source-build as they rely on external prebuilts. -->
Expand Down
3 changes: 1 addition & 2 deletions src/libraries/oob-src.proj
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
('$(BuildAllConfigurations)' != 'true' and '$(RuntimeFlavor)' == '$(PrimaryRuntimeFlavor)')" />

<!-- Don't build task and tools project in the NetCoreAppCurrent vertical. -->
<ProjectReference Remove="Microsoft.NETCore.Platforms\src\Microsoft.NETCore.Platforms.csproj;
Microsoft.XmlSerializer.Generator\src\Microsoft.XmlSerializer.Generator.csproj" />
<ProjectReference Remove="Microsoft.XmlSerializer.Generator\src\Microsoft.XmlSerializer.Generator.csproj" />

<!-- Don't build meta-projects in the NetCoreAppCurrent vertical. -->
<ProjectReference Remove="Microsoft.Internal.Runtime.AspNetCore.Transport\src\Microsoft.Internal.Runtime.AspNetCore.Transport.proj;
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/pretest.proj
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
Condition="'$(BuildTargetFramework)' == '$(NetCoreAppCurrent)' or '$(BuildTargetFramework)' == ''">
<!-- Shared framework deps file generation. Produces a test shared-framework deps file. -->
<GenerateTestSharedFrameworkDepsFile SharedFrameworkDirectory="$(NetCoreAppCurrentTestHostSharedFrameworkPath)"
RuntimeGraphFiles="$(RuntimeIdGraphDefinitionFile)"
RuntimeGraphFiles="$(BundledRuntimeIdentifierGraphFile)"
TargetRuntimeIdentifier="$(PackageRID)" />
</Target>

Expand Down

0 comments on commit cd2f0ff

Please sign in to comment.