Skip to content

Commit

Permalink
Restructure profiles following review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Jul 17, 2024
1 parent cf3c6e0 commit 9b0f78e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,23 @@ protected override void ExecuteCore()

private static TaskItem[] CreateKnownFrameworkReferences(string windowsSdkPackageVersion, string targetFrameworkVersion, string targetPlatformVersion)
{
// Return two profiles:
// Return two items:
// - "Windows": just the Windows SDK, without anything in Windows.UI.Xaml.*
// - "Full": with the entire Windows SDK (including Windows.UI.Xaml.* types)
// - No profile: with the entire Windows SDK (including Windows.UI.Xaml.* types)
return
[
CreateKnownFrameworkReference(windowsSdkPackageVersion, targetFrameworkVersion, targetPlatformVersion, "Windows"),
CreateKnownFrameworkReference(windowsSdkPackageVersion, targetFrameworkVersion, targetPlatformVersion, "Full"),
CreateKnownFrameworkReference(windowsSdkPackageVersion, targetFrameworkVersion, targetPlatformVersion, profile: "Windows"),
CreateKnownFrameworkReference(windowsSdkPackageVersion, targetFrameworkVersion, targetPlatformVersion, profile: null),
];
}

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

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

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

return knownFrameworkReference;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Copyright (c) .NET Foundation. All rights reserved.

<!-- Add the right Windows SDK projections depending on whether 'UseUwp' is also set in the project -->
<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" IsImplicitlyDefined="true" Pack="false" PrivateAssets="All" />
<FrameworkReference Condition=" '$(UseUwp)' != 'true' " Include="Microsoft.Windows.SDK.NET.Ref.Windows" IsImplicitlyDefined="true" Pack="false" PrivateAssets="All" />
</ItemGroup>

Expand Down Expand Up @@ -116,7 +116,7 @@ Copyright (c) .NET Foundation. All rights reserved.

</Target>

<!-- Target to emit an error when 'UseUwp' is not set, but 'Microsoft.Windows.SDK.NET.Ref.Full' is transitively referenced -->
<!-- Target to emit an error when 'UseUwp' is not set, but the full 'Microsoft.Windows.SDK.NET.Ref' item is transitively referenced -->
<Target Name="_CheckForTransitiveWindowsSDKFullDependencies"
AfterTargets="ResolvePackageAssets"
Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp'
Expand All @@ -125,7 +125,7 @@ Copyright (c) .NET Foundation. All rights reserved.
and '$(UseUwp)' != 'true' ">
<ItemGroup>
<_WindowsSDKFullTransitiveFrameworkReference Include="@(TransitiveFrameworkReference)"
Condition="'%(Identity)' == 'Microsoft.Windows.SDK.NET.Ref.Full'" />
Condition="'%(Identity)' == 'Microsoft.Windows.SDK.NET.Ref'" />
</ItemGroup>
<NetSdkError Condition="'@(_WindowsSDKFullTransitiveFrameworkReference)' != ''"
ResourceName="WindowsSDKFullMissingUseUwpProperty" />
Expand Down

0 comments on commit 9b0f78e

Please sign in to comment.