Skip to content

Commit 67783a8

Browse files
authored
Merge pull request #870 from natidea/skipMicrosoftNuGetTargets
Skip import of Microsoft.NuGet.props and Microsoft.NuGet.targets
2 parents c2739ae + 22fcace commit 67783a8

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ Copyright (c) .NET Foundation. All rights reserved.
8585

8686
<!-- This will turn off the base UWP-specific 'ResolveNuGetPackages' target -->
8787
<ResolveNuGetPackages>false</ResolveNuGetPackages>
88+
89+
<!-- Skip import of Microsoft.NuGet.props and Microsoft.NuGet.targets -->
90+
<SkipImportNuGetProps>true</SkipImportNuGetProps>
91+
<SkipImportNuGetBuildTargets>true</SkipImportNuGetBuildTargets>
8892

8993
<!-- NuGet should always restore .NET SDK projects with "PackageReference" style restore. Setting this property will
9094
cause the right thing to happen even if there aren't any PackageReference items in the project, such as when

test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,36 @@ public void It_targets_the_right_shared_framework(string targetFramework, string
7676
var netCoreAppLibrary = target.Libraries.Single(l => l.Name == "Microsoft.NETCore.App");
7777
netCoreAppLibrary.Version.ToString().Should().Be(expectedPackageVersion);
7878
}
79+
80+
[Fact]
81+
public void It_restores_only_ridless_tfm()
82+
{
83+
// Disable this test when using full Framework MSBuild, until MSBuild is updated
84+
// to provide conditions in NuGet ImportBefore/ImportAfter props/targets
85+
// https://github.com/dotnet/sdk/issues/874
86+
if (UsingFullFrameworkMSBuild)
87+
{
88+
return;
89+
}
90+
91+
var testAsset = _testAssetsManager
92+
.CopyTestAsset("HelloWorld")
93+
.WithSource()
94+
.Restore();
95+
96+
var getValuesCommand = new GetValuesCommand(Stage0MSBuild, testAsset.TestRoot,
97+
"netcoreapp1.0", "TargetDefinitions", GetValuesCommand.ValueType.Item);
98+
99+
getValuesCommand
100+
.Execute()
101+
.Should()
102+
.Pass();
103+
104+
// When RuntimeIdentifier is not specified, the assets file
105+
// should only contain one target with no RIDs
106+
var targetDefs = getValuesCommand.GetValues();
107+
targetDefs.Count.Should().Be(1);
108+
targetDefs.Should().Contain(".NETCoreApp,Version=v1.0");
109+
}
79110
}
80111
}

0 commit comments

Comments
 (0)