Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep apphostpack version in sync with targeting and runtime pack version #10030

Merged
merged 9 commits into from
Nov 5, 2024
15 changes: 15 additions & 0 deletions eng/Tools.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project>

<PropertyGroup>
<_RuntimeIdentifier Condition="'$(Platform)' == ''">win-x86</_RuntimeIdentifier>
<_RuntimeIdentifier Condition="'$(Platform)' != ''">win-$(Platform)</_RuntimeIdentifier>
</PropertyGroup>

<!-- Pre-download vcxproj dependencies as vcxprojs in this repo don't support NuGet package download. -->
<ItemGroup>
<PackageDownload Include="Microsoft.NETCore.App.Ref" Version="[$(MicrosoftNETCoreAppRefVersion)]" Condition="'$(MicrosoftNETCoreAppRefVersion)' != ''" />
<PackageDownload Include="Microsoft.NETCore.App.Runtime.$(_RuntimeIdentifier)" Version="[$(MicrosoftNETCoreAppRuntimewinx64Version)]" Condition="'$(MicrosoftNETCoreAppRuntimewinx64Version)' != ''" />
<PackageDownload Include="Microsoft.NETCore.App.Host.$(_RuntimeIdentifier)" Version="[$(MicrosoftNETCoreAppRuntimewinx64Version)]" Condition="'$(MicrosoftNETCoreAppRuntimewinx64Version)' != ''" />
</ItemGroup>

</Project>
94 changes: 80 additions & 14 deletions eng/WpfArcadeSdk/tools/RuntimeFrameworkReference.targets
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,93 @@
Version="$(MicrosoftNETCorePlatformsVersion)"
Condition="'$(ManagedCxx)'=='true'"/>

<FrameworkReference Update="Microsoft.NETCore.App"
Condition="'$(MicrosoftNETCoreAppRefVersion)'!=''
And '$(NoTargets)'!='true'
And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'
And $([MSBuild]::VersionGreaterThanOrEquals('$(TargetFrameworkVersion)', '3.0'))
And '$(MSBuildProjectExtension)'!='.vcxproj'">
<TargetingPackVersion>$(MicrosoftNETCoreAppRefVersion)</TargetingPackVersion>
</FrameworkReference>

<!--
Workaround - this should be removed when our tests are converted from Microsoft.NET.Sdk.WindowsDesktop => Microsoft.NET.Sdk
project
-->
<KnownFrameworkReference Remove="Microsoft.AspNetCore.App" />
</ItemGroup>

<!-- The below logic intentionally doesn't consider multiple .NETCoreApp TFMs as that isn't necessary at this point. -->
<PropertyGroup>
<RuntimeFrameworkVersion Condition="'$(MicrosoftNETCoreAppRuntimewinx64Version)'!='' And
'$(NoTargets)'!='true' And
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' And
$([MSBuild]::VersionGreaterThanOrEquals('$(TargetFrameworkVersion)', '3.0')) And
'$(MSBuildProjectExtension)'!='.vcxproj'">$(MicrosoftNETCoreAppRuntimewinx64Version)</RuntimeFrameworkVersion>
<UseOOBNETCoreAppTargetingPack Condition="'$(UseOOBNETCoreAppTargetingPack)' == ''">true</UseOOBNETCoreAppTargetingPack>
<UseOOBNETCoreAppRuntimePack Condition="'$(UseOOBNETCoreAppRuntimePack)' == ''">true</UseOOBNETCoreAppRuntimePack>
<UseOOBNETCoreAppAppHostPack Condition="'$(UseOOBNETCoreAppAppHostPack)' == ''">true</UseOOBNETCoreAppAppHostPack>
</PropertyGroup>

<PropertyGroup>
<!-- vcxproj don't support restore -->
<EnableTargetingPackDownload Condition="'$(UseOOBNETCoreAppTargetingPack)' == 'true' and '$(MSBuildProjectExtension)' == '.vcxproj'">false</EnableTargetingPackDownload>
<EnableRuntimePackDownload Condition="'$(UseOOBNETCoreAppRuntimePack)' == 'true' and '$(MSBuildProjectExtension)' == '.vcxproj'">false</EnableRuntimePackDownload>
<GenerateErrorForMissingTargetingPacks Condition="'$(EnableTargetingPackDownload)' == 'false'">false</GenerateErrorForMissingTargetingPacks>

<EnableAppHostPackDownload Condition="'$(UseOOBNETCoreAppAppHostPack)' == 'true' and '$(MSBuildProjectExtension)' == '.vcxproj'">false</EnableAppHostPackDownload>
</PropertyGroup>

<ItemGroup>
<KnownFrameworkReference Update="Microsoft.NETCore.App">
ViktorHofer marked this conversation as resolved.
Show resolved Hide resolved
<TargetingPackVersion Condition="'$(UseOOBNETCoreAppTargetingPack)' == 'true'">$(MicrosoftNETCoreAppRefVersion)</TargetingPackVersion>
<DefaultRuntimeFrameworkVersion Condition="'$(UseOOBNETCoreAppRuntimePack)' == 'true'">$(MicrosoftNETCoreAppRuntimewinx64Version)</DefaultRuntimeFrameworkVersion>
<LatestRuntimeFrameworkVersion Condition="'$(UseOOBNETCoreAppRuntimePack)' == 'true'">$(MicrosoftNETCoreAppRuntimewinx64Version)</LatestRuntimeFrameworkVersion>
</KnownFrameworkReference>

<KnownRuntimePack Update="Microsoft.NETCore.App"
LatestRuntimeFrameworkVersion="$(MicrosoftNETCoreAppRuntimewinx64Version)"
Condition="'$(UseOOBNETCoreAppRuntimePack)' == 'true'" />

<KnownAppHostPack Update="Microsoft.NETCore.App"
AppHostPackVersion="$(MicrosoftNETCoreAppRuntimewinx64Version)"
Condition="'$(UseOOBNETCoreAppAppHostPack)' == 'true'" />
</ItemGroup>

<!-- Update paths for resolved packs which is necessary when the packs couldn't be resolved.
This happens when package download is disabled and the package isn't available in the SDK's packs folder.
This entire target can be removed when vcxproj's NuGet support gets enabled. -->
<Target Name="UpdateOOBPacks"
Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'"
AfterTargets="ResolveFrameworkReferences">
<ItemGroup>
<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)' == ''" />
<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)' == ''" />

<ResolvedTargetingPack Path="$(NuGetPackageRoot)microsoft.netcore.app.ref\$(MicrosoftNETCoreAppRefVersion)"
NuGetPackageVersion="$(MicrosoftNETCoreAppRefVersion)"
PackageDirectory="$(NuGetPackageRoot)microsoft.netcore.app.ref\$(MicrosoftNETCoreAppRefVersion)"
Condition="'$(UseOOBNETCoreAppTargetingPack)' == 'true' and '$(EnableTargetingPackDownload)' == 'false' and '%(ResolvedTargetingPack.RuntimeFrameworkName)' == 'Microsoft.NETCore.App'" />

<ResolvedRuntimePack PackageDirectory="$(NuGetPackageRoot)microsoft.netcore.app.runtime.%(RuntimeIdentifier)\$(MicrosoftNETCoreAppRuntimewinx64Version)"
NuGetPackageVersion="$(MicrosoftNETCoreAppRuntimewinx64Version)"
Condition="'$(UseOOBNETCoreAppRuntimePack)' == 'true' and '$(EnableRuntimePackDownload)' == 'false' and '%(ResolvedRuntimePack.FrameworkName)' == 'Microsoft.NETCore.App'" />
</ItemGroup>

<PropertyGroup>
<_ResolvedRuntimePackPath>@(ResolvedRuntimePack->WithMetadataValue('FrameworkName', 'Microsoft.NETCore.App')->Metadata('Path'))</_ResolvedRuntimePackPath>
</PropertyGroup>

<ItemGroup>
<ResolvedFrameworkReference Condition="'%(Identity)' == 'Microsoft.NETCore.App'">
<TargetingPackPath Condition="'$(UseOOBNETCoreAppTargetingPack)' == 'true' and '$(EnableTargetingPackDownload)' == 'false'">$(NuGetPackageRoot)microsoft.netcore.app.ref\$(MicrosoftNETCoreAppRefVersion)</TargetingPackPath>
<TargetingPackVersion Condition="'$(UseOOBNETCoreAppTargetingPack)' == 'true' and '$(EnableTargetingPackDownload)' == 'false'">$(MicrosoftNETCoreAppRefVersion)</TargetingPackVersion>
<RuntimePackPath Condition="'$(UseOOBNETCoreAppRuntimePack)' == 'true' and '$(EnableRuntimePackDownload)' == 'false'">$(_ResolvedRuntimePackPath)</RuntimePackPath>
<RuntimePackVersion Condition="'$(UseOOBNETCoreAppRuntimePack)' == 'true' and '$(EnableRuntimePackDownload)' == 'false'">$(MicrosoftNETCoreAppRuntimewinx64Version)</RuntimePackVersion>
</ResolvedFrameworkReference>

<ResolvedAppHostPack Path="$(NuGetPackageRoot)microsoft.netcore.app.host.%(RuntimeIdentifier)\$(MicrosoftNETCoreAppRuntimewinx64Version)\%(ResolvedAppHostPack.PathInPackage)"
PackageDirectory="$(NuGetPackageRoot)microsoft.netcore.app.host.%(RuntimeIdentifier)\$(MicrosoftNETCoreAppRuntimewinx64Version)"
Condition="'$(UseOOBNETCoreAppAppHostPack)' == 'true' and '$(EnableAppHostPackDownload)' == 'false'" />

<ResolvedIjwHostPack Path="$(NuGetPackageRoot)microsoft.netcore.app.host.%(RuntimeIdentifier)\$(MicrosoftNETCoreAppRuntimewinx64Version)\%(ResolvedIjwHostPack.PathInPackage)"
PackageDirectory="$(NuGetPackageRoot)microsoft.netcore.app.host.%(RuntimeIdentifier)\$(MicrosoftNETCoreAppRuntimewinx64Version)"
Condition="'$(UseOOBNETCoreAppAppHostPack)' == 'true' and '$(EnableAppHostPackDownload)' == 'false'" />
</ItemGroup>

<PropertyGroup Condition="'@(ResolvedAppHostPack)' != '' And '$(AppHostSourcePath)' == ''">
<AppHostSourcePath>@(ResolvedAppHostPack->'%(Path)')</AppHostSourcePath>
</PropertyGroup>

<PropertyGroup Condition="'@(ResolvedIjwHostPack)' != '' And '$(IjwHostSourcePath)' == ''">
<IjwHostSourcePath>@(ResolvedIjwHostPack->'%(Path)')</IjwHostSourcePath>
</PropertyGroup>
</Target>

</Project>