Skip to content

Commit

Permalink
Always specify a profile for all TFMs
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Jul 15, 2024
1 parent 4ef04e8 commit d9a21c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,7 @@ protected override void ExecuteCore()

private static TaskItem[] CreateKnownFrameworkReferences(string windowsSdkPackageVersion, string targetFrameworkVersion, string targetPlatformVersion)
{
// The two profiles are only available starting from .NET 9
if (Version.Parse(targetPlatformVersion) < new Version(9, 0))
{
return [CreateKnownFrameworkReference(windowsSdkPackageVersion, targetFrameworkVersion, targetPlatformVersion, profile: "")];
}

// Return two profiles when on .NET 9:
// Return two profiles:
// - "Windows": just the Windows SDK, without anything in Windows.UI.Xaml.*
// - "Full": with the entire Windows SDK (including Windows.UI.Xaml.* types)
return
Expand All @@ -115,11 +109,7 @@ private static TaskItem[] CreateKnownFrameworkReferences(string windowsSdkPackag

private static TaskItem CreateKnownFrameworkReference(string windowsSdkPackageVersion, string targetFrameworkVersion, string targetPlatformVersion, string profile)
{
string itemSpec = string.IsNullOrEmpty(profile)
? "Microsoft.Windows.SDK.NET.Ref"
: $"Microsoft.Windows.SDK.NET.Ref.{profile}";

var knownFrameworkReference = new TaskItem(itemSpec);
var knownFrameworkReference = new TaskItem($"Microsoft.Windows.SDK.NET.Ref.{profile}");
knownFrameworkReference.SetMetadata("TargetFramework", $"net{targetFrameworkVersion}-windows{targetPlatformVersion}");
knownFrameworkReference.SetMetadata("RuntimeFrameworkName", "Microsoft.Windows.SDK.NET.Ref");
knownFrameworkReference.SetMetadata("DefaultRuntimeFrameworkVersion", windowsSdkPackageVersion);
Expand All @@ -130,11 +120,7 @@ private static TaskItem CreateKnownFrameworkReference(string windowsSdkPackageVe
knownFrameworkReference.SetMetadata("RuntimePackNamePatterns", "Microsoft.Windows.SDK.NET.Ref");
knownFrameworkReference.SetMetadata("RuntimePackRuntimeIdentifiers", "any");
knownFrameworkReference.SetMetadata("IsWindowsOnly", "true");

if (!string.IsNullOrEmpty(profile))
{
knownFrameworkReference.SetMetadata("Profile", profile);
}
knownFrameworkReference.SetMetadata("Profile", profile);

return knownFrameworkReference;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,11 @@ Copyright (c) .NET Foundation. All rights reserved.
</PropertyGroup>

<!-- Add the right Windows SDK projections depending on whether 'UseUwp' is also set in the project -->
<ItemGroup Condition=" '$(IncludeWindowsSDKRefFrameworkReferences)' == 'true'
and $([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '9.0'))">
<ItemGroup Condition=" '$(IncludeWindowsSDKRefFrameworkReferences)' == 'true' ">
<FrameworkReference Condition=" '$(UseUwp)' == 'true' " Include="Microsoft.Windows.SDK.NET.Ref.Full" IsImplicitlyDefined="true" Pack="false" PrivateAssets="All" />
<FrameworkReference Condition=" '$(UseUwp)' != 'true' " Include="Microsoft.Windows.SDK.NET.Ref.Windows" IsImplicitlyDefined="true" Pack="false" PrivateAssets="All" />
</ItemGroup>

<!-- Fallback for previous framework packages -->
<ItemGroup Condition=" '$(IncludeWindowsSDKRefFrameworkReferences)' == 'true'
and !$([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '9.0'))">
<FrameworkReference Include="Microsoft.Windows.SDK.NET.Ref" IsImplicitlyDefined="true" Pack="false" PrivateAssets="All" />
</ItemGroup>

<!-- Default 'CsWinRTUseWindowsUIXamlProjections' to 'false', unless 'UseUwp' is set.
This is to ensure that using the full Windows SDK projections will work correctly.
We still allow users to override this, which can help in mixed WinAppSDK scenarios. -->
Expand Down Expand Up @@ -125,7 +118,6 @@ Copyright (c) .NET Foundation. All rights reserved.
<Target Name="_CheckForTransitiveWindowsSDKFullDependencies"
AfterTargets="ResolvePackageAssets"
Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp'
and $([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '9.0'))
and '$(TargetPlatformIdentifier)' == 'Windows'
and '@(TransitiveFrameworkReference)' != ''
and '$(UseUwp)' != 'true' ">
Expand Down

0 comments on commit d9a21c0

Please sign in to comment.