Skip to content

Commit 4ac3507

Browse files
authored
Keep apphostpack version in sync with targeting and runtime pack version (#10030)
* Keep apphostpack version in sync with targeting and runtime pack version Unblocks dotnet/sdk#43015 WPF uses a "live" version of the .NETCoreApp targeting and runtime pack. Also use the live version for the apphost pack so that vcxprojs don't depend on the version inside the SDK. * Update RuntimeFrameworkReference.targets * Create Tools.props * Update RuntimeFrameworkReference.targets * Update RuntimeFrameworkReference.targets * Update RuntimeFrameworkReference.targets * Update Tools.props * PR feedback and adding comments * Add more comments and consider version properties in conditions
1 parent 68baa81 commit 4ac3507

File tree

2 files changed

+95
-14
lines changed

2 files changed

+95
-14
lines changed

Diff for: eng/Tools.props

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project>
2+
3+
<PropertyGroup>
4+
<_RuntimeIdentifier Condition="'$(Platform)' == ''">win-x86</_RuntimeIdentifier>
5+
<_RuntimeIdentifier Condition="'$(Platform)' != ''">win-$(Platform)</_RuntimeIdentifier>
6+
</PropertyGroup>
7+
8+
<!-- Pre-download vcxproj dependencies as vcxprojs in this repo don't support NuGet package download. -->
9+
<ItemGroup>
10+
<PackageDownload Include="Microsoft.NETCore.App.Ref" Version="[$(MicrosoftNETCoreAppRefVersion)]" Condition="'$(MicrosoftNETCoreAppRefVersion)' != ''" />
11+
<PackageDownload Include="Microsoft.NETCore.App.Runtime.$(_RuntimeIdentifier)" Version="[$(MicrosoftNETCoreAppRuntimewinx64Version)]" Condition="'$(MicrosoftNETCoreAppRuntimewinx64Version)' != ''" />
12+
<PackageDownload Include="Microsoft.NETCore.App.Host.$(_RuntimeIdentifier)" Version="[$(MicrosoftNETCoreAppRuntimewinx64Version)]" Condition="'$(MicrosoftNETCoreAppRuntimewinx64Version)' != ''" />
13+
</ItemGroup>
14+
15+
</Project>

Diff for: eng/WpfArcadeSdk/tools/RuntimeFrameworkReference.targets

+80-14
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,93 @@
1212
Version="$(MicrosoftNETCorePlatformsVersion)"
1313
Condition="'$(ManagedCxx)'=='true'"/>
1414

15-
<FrameworkReference Update="Microsoft.NETCore.App"
16-
Condition="'$(MicrosoftNETCoreAppRefVersion)'!=''
17-
And '$(NoTargets)'!='true'
18-
And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'
19-
And $([MSBuild]::VersionGreaterThanOrEquals('$(TargetFrameworkVersion)', '3.0'))
20-
And '$(MSBuildProjectExtension)'!='.vcxproj'">
21-
<TargetingPackVersion>$(MicrosoftNETCoreAppRefVersion)</TargetingPackVersion>
22-
</FrameworkReference>
23-
2415
<!--
2516
Workaround - this should be removed when our tests are converted from Microsoft.NET.Sdk.WindowsDesktop => Microsoft.NET.Sdk
2617
project
2718
-->
2819
<KnownFrameworkReference Remove="Microsoft.AspNetCore.App" />
2920
</ItemGroup>
3021

22+
<!-- The below logic intentionally doesn't consider multiple .NETCoreApp TFMs as that isn't necessary at this point. -->
23+
<PropertyGroup>
24+
<UseOOBNETCoreAppTargetingPack Condition="'$(UseOOBNETCoreAppTargetingPack)' == '' and '$(MicrosoftNETCoreAppRefVersion)' != ''">true</UseOOBNETCoreAppTargetingPack>
25+
<UseOOBNETCoreAppRuntimePack Condition="'$(UseOOBNETCoreAppRuntimePack)' == '' and '$(MicrosoftNETCoreAppRuntimewinx64Version)' != ''">true</UseOOBNETCoreAppRuntimePack>
26+
<UseOOBNETCoreAppAppHostPack Condition="'$(UseOOBNETCoreAppAppHostPack)' == '' and '$(MicrosoftNETCoreAppRuntimewinx64Version)' != ''">true</UseOOBNETCoreAppAppHostPack>
27+
</PropertyGroup>
28+
29+
<ItemGroup>
30+
<KnownFrameworkReference Update="Microsoft.NETCore.App">
31+
<TargetingPackVersion Condition="'$(UseOOBNETCoreAppTargetingPack)' == 'true'">$(MicrosoftNETCoreAppRefVersion)</TargetingPackVersion>
32+
<DefaultRuntimeFrameworkVersion Condition="'$(UseOOBNETCoreAppRuntimePack)' == 'true'">$(MicrosoftNETCoreAppRuntimewinx64Version)</DefaultRuntimeFrameworkVersion>
33+
<LatestRuntimeFrameworkVersion Condition="'$(UseOOBNETCoreAppRuntimePack)' == 'true'">$(MicrosoftNETCoreAppRuntimewinx64Version)</LatestRuntimeFrameworkVersion>
34+
</KnownFrameworkReference>
35+
36+
<KnownRuntimePack Update="Microsoft.NETCore.App"
37+
LatestRuntimeFrameworkVersion="$(MicrosoftNETCoreAppRuntimewinx64Version)"
38+
Condition="'$(UseOOBNETCoreAppRuntimePack)' == 'true'" />
39+
40+
<KnownAppHostPack Update="Microsoft.NETCore.App"
41+
AppHostPackVersion="$(MicrosoftNETCoreAppRuntimewinx64Version)"
42+
Condition="'$(UseOOBNETCoreAppAppHostPack)' == 'true'" />
43+
</ItemGroup>
44+
45+
<!-- These properties can be removed when vcxproj's NuGet support gets enabled. -->
3146
<PropertyGroup>
32-
<RuntimeFrameworkVersion Condition="'$(MicrosoftNETCoreAppRuntimewinx64Version)'!='' And
33-
'$(NoTargets)'!='true' And
34-
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' And
35-
$([MSBuild]::VersionGreaterThanOrEquals('$(TargetFrameworkVersion)', '3.0')) And
36-
'$(MSBuildProjectExtension)'!='.vcxproj'">$(MicrosoftNETCoreAppRuntimewinx64Version)</RuntimeFrameworkVersion>
47+
<EnableTargetingPackDownload Condition="'$(UseOOBNETCoreAppTargetingPack)' == 'true' and '$(MSBuildProjectExtension)' == '.vcxproj'">false</EnableTargetingPackDownload>
48+
<EnableRuntimePackDownload Condition="'$(UseOOBNETCoreAppRuntimePack)' == 'true' and '$(MSBuildProjectExtension)' == '.vcxproj'">false</EnableRuntimePackDownload>
49+
<GenerateErrorForMissingTargetingPacks Condition="'$(EnableTargetingPackDownload)' == 'false'">false</GenerateErrorForMissingTargetingPacks>
50+
51+
<EnableAppHostPackDownload Condition="'$(UseOOBNETCoreAppAppHostPack)' == 'true' and '$(MSBuildProjectExtension)' == '.vcxproj'">false</EnableAppHostPackDownload>
3752
</PropertyGroup>
53+
54+
<!-- Update paths for resolved packs which is necessary when the packs couldn't be resolved.
55+
This happens when package download is disabled and the package isn't available in the SDK's packs folder.
56+
This entire target can be removed when vcxproj's NuGet support gets enabled. -->
57+
<Target Name="UpdateOOBPacks"
58+
Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'"
59+
AfterTargets="ResolveFrameworkReferences">
60+
<ItemGroup>
61+
<Error Text="'MicrosoftNETCoreAppRefVersion' is not set. Please set it to the version of the targeting pack you want to use." Condition="'$(UseOOBNETCoreAppTargetingPack)' == 'true' and '$(MicrosoftNETCoreAppRefVersion)' == ''" />
62+
<Error Text="'MicrosoftNETCoreAppRuntimewinx64Version' is not set. Please set it to the version of the runtime pack you want to use." Condition="('$(UseOOBNETCoreAppRuntimePack)' == 'true' or '$(UseOOBNETCoreAppAppHostPack)' == 'true') and '$(MicrosoftNETCoreAppRuntimewinx64Version)' == ''" />
63+
64+
<ResolvedTargetingPack Path="$(NuGetPackageRoot)microsoft.netcore.app.ref\$(MicrosoftNETCoreAppRefVersion)"
65+
NuGetPackageVersion="$(MicrosoftNETCoreAppRefVersion)"
66+
PackageDirectory="$(NuGetPackageRoot)microsoft.netcore.app.ref\$(MicrosoftNETCoreAppRefVersion)"
67+
Condition="'$(UseOOBNETCoreAppTargetingPack)' == 'true' and '$(EnableTargetingPackDownload)' == 'false' and '%(ResolvedTargetingPack.RuntimeFrameworkName)' == 'Microsoft.NETCore.App'" />
68+
69+
<ResolvedRuntimePack PackageDirectory="$(NuGetPackageRoot)microsoft.netcore.app.runtime.%(RuntimeIdentifier)\$(MicrosoftNETCoreAppRuntimewinx64Version)"
70+
NuGetPackageVersion="$(MicrosoftNETCoreAppRuntimewinx64Version)"
71+
Condition="'$(UseOOBNETCoreAppRuntimePack)' == 'true' and '$(EnableRuntimePackDownload)' == 'false' and '%(ResolvedRuntimePack.FrameworkName)' == 'Microsoft.NETCore.App'" />
72+
</ItemGroup>
73+
74+
<PropertyGroup>
75+
<_ResolvedRuntimePackPath>@(ResolvedRuntimePack->WithMetadataValue('FrameworkName', 'Microsoft.NETCore.App')->Metadata('Path'))</_ResolvedRuntimePackPath>
76+
</PropertyGroup>
77+
78+
<ItemGroup>
79+
<ResolvedFrameworkReference Condition="'%(Identity)' == 'Microsoft.NETCore.App'">
80+
<TargetingPackPath Condition="'$(UseOOBNETCoreAppTargetingPack)' == 'true' and '$(EnableTargetingPackDownload)' == 'false'">$(NuGetPackageRoot)microsoft.netcore.app.ref\$(MicrosoftNETCoreAppRefVersion)</TargetingPackPath>
81+
<TargetingPackVersion Condition="'$(UseOOBNETCoreAppTargetingPack)' == 'true' and '$(EnableTargetingPackDownload)' == 'false'">$(MicrosoftNETCoreAppRefVersion)</TargetingPackVersion>
82+
<RuntimePackPath Condition="'$(UseOOBNETCoreAppRuntimePack)' == 'true' and '$(EnableRuntimePackDownload)' == 'false'">$(_ResolvedRuntimePackPath)</RuntimePackPath>
83+
<RuntimePackVersion Condition="'$(UseOOBNETCoreAppRuntimePack)' == 'true' and '$(EnableRuntimePackDownload)' == 'false'">$(MicrosoftNETCoreAppRuntimewinx64Version)</RuntimePackVersion>
84+
</ResolvedFrameworkReference>
85+
86+
<ResolvedAppHostPack Path="$(NuGetPackageRoot)microsoft.netcore.app.host.%(RuntimeIdentifier)\$(MicrosoftNETCoreAppRuntimewinx64Version)\%(ResolvedAppHostPack.PathInPackage)"
87+
PackageDirectory="$(NuGetPackageRoot)microsoft.netcore.app.host.%(RuntimeIdentifier)\$(MicrosoftNETCoreAppRuntimewinx64Version)"
88+
Condition="'$(UseOOBNETCoreAppAppHostPack)' == 'true' and '$(EnableAppHostPackDownload)' == 'false'" />
89+
90+
<ResolvedIjwHostPack Path="$(NuGetPackageRoot)microsoft.netcore.app.host.%(RuntimeIdentifier)\$(MicrosoftNETCoreAppRuntimewinx64Version)\%(ResolvedIjwHostPack.PathInPackage)"
91+
PackageDirectory="$(NuGetPackageRoot)microsoft.netcore.app.host.%(RuntimeIdentifier)\$(MicrosoftNETCoreAppRuntimewinx64Version)"
92+
Condition="'$(UseOOBNETCoreAppAppHostPack)' == 'true' and '$(EnableAppHostPackDownload)' == 'false'" />
93+
</ItemGroup>
94+
95+
<PropertyGroup Condition="'@(ResolvedAppHostPack)' != '' And '$(AppHostSourcePath)' == ''">
96+
<AppHostSourcePath>@(ResolvedAppHostPack->'%(Path)')</AppHostSourcePath>
97+
</PropertyGroup>
98+
99+
<PropertyGroup Condition="'@(ResolvedIjwHostPack)' != '' And '$(IjwHostSourcePath)' == ''">
100+
<IjwHostSourcePath>@(ResolvedIjwHostPack->'%(Path)')</IjwHostSourcePath>
101+
</PropertyGroup>
102+
</Target>
103+
38104
</Project>

0 commit comments

Comments
 (0)