Skip to content

Don't download Windows SDK ref pack for C++ projects #44956

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ Copyright (c) .NET Foundation. All rights reserved.
<UsingTask TaskName="ProcessFrameworkReferences" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
<UsingTask TaskName="ResolveAppHosts" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />


<!-- Don't add Windows SDK framework reference for C++ by default, as C++ doesn't use it and it would be an unnecessary download for possible
transitive framework references. -->
<Target Name="AddWindowsSdkKnownFrameworkReferences"
Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' And '$(TargetPlatformIdentifier)' == 'Windows'">
Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' And '$(TargetPlatformIdentifier)' == 'Windows'
And ('$(Language)' != 'C++' Or '$(IncludeWindowsSDKRefFrameworkReferences)' == 'true')">

<!-- Remove Windows SDK KnownFrameworkReference items from BundledVersions.props (they will eventually be removed, but that is in a different repo so
we can't do the change atomically). -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,32 @@ public void It_builds_and_runs_with_package_reference()
var testAsset = _testAssetsManager
.CopyTestAsset("NetCoreCsharpAppReferenceCppCliLib")
.WithSource()
.WithProjectChanges((projectPath, project) => ConfigureProject(projectPath, project, targetFramework, new string[] { "_EnablePackageReferencesInVCProjects", "IncludeWindowsSDKRefFrameworkReferences" }));
.WithProjectChanges((projectPath, project) =>
{
ConfigureProject(projectPath, project, targetFramework, new string[] { "_EnablePackageReferencesInVCProjects", "IncludeWindowsSDKRefFrameworkReferences" });

var ns = project.Root.Name.Namespace;
// Use project-specific global packages folder so we can check what was downloaded
project.Root.Element(ns + "PropertyGroup")
.Add(new XElement(ns + "RestorePackagesPath", @"$(MSBuildProjectDirectory)\packages"));

});

new BuildCommand(testAsset, "NETCoreCppCliTest")
.Execute("-p:Platform=x64")
.WithWorkingDirectory(testAsset.TestRoot)
.Execute("-p:Platform=x64", "/bl")
.Should()
.Pass();

var cppnProjProperties = GetPropertyValues(testAsset.TestRoot, "NETCoreCppCliTest", targetFramework: targetFramework);
Assert.True(cppnProjProperties["_EnablePackageReferencesInVCProjects"] == "true");
Assert.True(cppnProjProperties["IncludeWindowsSDKRefFrameworkReferences"] == "");

var packagesFolder = Path.Combine(testAsset.TestRoot, "NETCoreCppCliTest", "packages");
if (Directory.Exists(packagesFolder))
{
new DirectoryInfo(packagesFolder).Should().NotHaveSubDirectories("microsoft.windows.sdk.net.ref");
}
}

[FullMSBuildOnlyFact]
Expand Down
Loading