Skip to content

Commit

Permalink
Merge pull request #952 from CommunityToolkit/dev/update-framework-re…
Browse files Browse the repository at this point in the history
…ference-checks

Update SDK package checks for .NET 9 SDK
  • Loading branch information
Sergio0694 committed Sep 18, 2024
1 parent 3c74216 commit 760c8aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.WindowsSdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,21 @@
<Recommended>10.0.$([System.Version]::Parse("$(WindowsSdkPackageVersion.Split('-')[0])").Build).$(_MvvmToolkitWindowsSdkPackageRecommendedBuild)</Recommended>
</_MvvmToolkitWindowsSdkPackage>

<!-- Otherwise, validate against the framework reference package -->
<!--
Otherwise, validate against the framework reference package. We need to check for two different item specs:
- "Microsoft.Windows.SDK.NET.Ref": this is the default name for the framework reference for the Windows
SDK projections, used on .NET 8 and lower. It includes all Windows APIs, except for XAML.
- "Microsoft.Windows.SDK.NET.Ref.Windows": this is the same as bove, except it's the framework reference
name that is added by the .NET 9 SDK for projects targeting .NET 8 and above. This specifically includes
the "Windows" profile, which only references non-XAML APIs. This change was done for the UWP support for
.NET 9, which requires the .NET SDK to also be able to reference XAML types. Those will use a different
item spec (ie. "Microsoft.Windows.SDK.NET.Ref.Xaml"). We only need to check the base "Windows" reference.
-->
<_MvvmToolkitWindowsSdkPackage
Include="@(ResolvedFrameworkReference)"
Condition="'$(WindowsSdkPackageVersion)' == '' AND '@(ResolvedFrameworkReference)' != '' AND '%(Identity)' == 'Microsoft.Windows.SDK.NET.Ref'">
Condition="'$(WindowsSdkPackageVersion)' == '' AND
'@(ResolvedFrameworkReference)' != '' AND
('%(Identity)' == 'Microsoft.Windows.SDK.NET.Ref' OR '%(Identity)' == 'Microsoft.Windows.SDK.NET.Ref.Windows')">
<Referenced>%(ResolvedFrameworkReference.TargetingPackVersion)</Referenced>
<Required>10.0.$([System.Version]::Parse("%(ResolvedFrameworkReference.TargetingPackVersion)").Build).$(_MvvmToolkitWindowsSdkPackageMinBuild)</Required>
<Recommended>10.0.$([System.Version]::Parse("%(ResolvedFrameworkReference.TargetingPackVersion)").Build).$(_MvvmToolkitWindowsSdkPackageRecommendedBuild)</Recommended>
Expand Down
2 changes: 1 addition & 1 deletion src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

<!-- Reference CsWinRT when targeting Windows, to get the latest source generators -->
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0-windows10.0.17763.0'))">
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.3" PrivateAssets="all" />
</ItemGroup>

<!-- Reference the various multi-targeted versions of the source generator project (one per Roslyn version), and the code fixer -->
Expand Down

0 comments on commit 760c8aa

Please sign in to comment.