-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Skip import of Microsoft.NuGet.props and Microsoft.NuGet.targets #870
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
Conversation
@@ -577,5 +577,15 @@ public void It_passes_ridless_target_to_compiler() | |||
.Should() | |||
.Pass(); | |||
} | |||
|
|||
[Fact] | |||
public void It_restores_only_ridless_tfm() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note this test passes even without this fix because it uses dotnet.exe which already excludes Microsoft.NuGet.targets. But this seems like a good scenario to ensure we don't regress.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you'll get coverage from the full msbuild runs in Jenkins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you'll get coverage from the full msbuild runs in Jenkins.
Yes, if this isn't failing in the full MSBuild Jenkins run, then I think it's not testing what we think it is (since the corresponding change to the NuGet targets isn't on the Jevkins machine). I'd like us to understand why this is the case.
You can run tests against full MSBuild locally with build -FullMSBuild
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build -FullMSBuild
did not fail.
Does "Full MSBuild" mean the sdk and targets under %VSINSTALLDIR%
or under .dotnet_cli
. I assume its under .dotnet_cli
. In this case, these are the same "ImportAfter" targets used by the CLI i.e. they have already removed Microsoft.NuGet.targets (see .dotnet_cli\sdk\1.0.0-rc4-004771\15.0\Microsoft.Common.targets\ImportAfter\Microsoft.NuGet.ImportAfter.targets
)
I inspected the project.assets.json generated for the test under bin\Debug\Tests
, and it only contains one (ridless) targets entry, so the test is correctly passing, but would fail if we were using the MSBuild under %VSINSTALLDIR%
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Full msbuild means the one in VS. Pasting my comment to this thread as well:
I assume it's not failing because the Jenkins machines won't have the corresponding change in NuGet.targets that adds a condition to skip import with these properties. When we move Jenkins to a build with the VS side change then it'll start failing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK figured it out. For some reason, the multiple rid problem only repros on apps targeting netcoreapp1.0
, not on libraries targeting netstandard1.5
. I guess some combination of the conditions in Microsoft.NuGet.targets is only affecting these projects, but its not obvious which ones. (To confirm, New NetStandard Library -> Add System.ValueTuple, does not produce any warnings.)
I've moved the test to GivenThatWeWantToBuildANetCoreApp
and modified it to check values from the HelloWorld
app. Now build
passes, but build -FullMSBuild
fails. I'll push this change to confirm Jenkins fails, then disable the test until we update Jenkins.
So the downgrades will still occur for projects that add RIDs themselves? If so, this only lessens the case where you'll see them and we still haven't gotten to the root of the issue. I thought there was actually a problem with the authoring of packages like System.ValueTuple. I just needed to separately add default RIDs to restore of multitargeting project for #847, so if I've understood, the same behavior would show up in that case (only deterministically in both VS and CLI). |
Yes this only lessens the situations where this happens. The ValueTuple package itself is being fixed and #821 tracks doing something about the downgrade warnings for other packages (not sure what). |
Wow this will fix the 5000 warnings we kept seeing in corefxlab! /cc @pakrym |
@davidfowl those were fixed by dotnet/corefxlab#1218 but this fixes the root cause |
@dotnet-bot test this please |
Tagging @MattGertz for approval. |
@@ -577,5 +577,15 @@ public void It_passes_ridless_target_to_compiler() | |||
.Should() | |||
.Pass(); | |||
} | |||
|
|||
[Fact] | |||
public void It_restores_only_ridless_tfm() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you'll get coverage from the full msbuild runs in Jenkins.
Yes, if this isn't failing in the full MSBuild Jenkins run, then I think it's not testing what we think it is (since the corresponding change to the NuGet targets isn't on the Jevkins machine). I'd like us to understand why this is the case.
You can run tests against full MSBuild locally with build -FullMSBuild
.
I assume it's not failing because the Jenkins machines won't have the corresponding change in NuGet.targets that adds a condition to skip import with these properties. When we move Jenkins to a build with the VS side change then it'll start failing |
@srivatsn its the other way round. The test expects only one target definition. If we were running with MSBuild under |
Ah yes.. then I agree with Daniel. It's fishy that it isn't failing with the full msbuild. |
…of NETStandard library
Jenkins FullFramework tests failed as expected: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. You could disable the test only when running on full framework, as we do here, for example.
…eapps when UsingFullFrameworkMSBuild dotnet#874
Approved to merge via 385238 |
…0190811.2 (dotnet#870) - Microsoft.AspNetCore.Mvc.Analyzers - 3.0.0-preview9.19411.2 - Microsoft.AspNetCore.Mvc.Api.Analyzers - 3.0.0-preview9.19411.2 - Microsoft.AspNetCore.Analyzers - 3.0.0-preview9.19411.2 - Microsoft.AspNetCore.Components.Analyzers - 3.0.0-preview9.19411.2
Fixes dotnet/project-system#1474 and dotnet/project-system#1508
Customer scenario
Customers restoring projects with reference to certain packages (e.g. System.ValueTuple) will see hundreds of downgrade warnings, when they restore from Visual Studio. However they don't see those same warnings when restoring from the CLI.
The root cause is that the VS targets automatically import Microsoft.NuGet.targets, which contains legacy properties and targets associated with project.json. This targets file is specified as an automatic "ImportAfter" Microsoft.Common.targets for all project types. Other errors are sometimes reported because of the inclusion of this file (dotnet/project-system#1508). The downgrade warnings occur because more RIDs are restored than are specified because of this property in Microsoft.NuGet.targets:
The CLI dropped this file from their version of ImportAfter, however VS cannot drop it since it is used by other project types. This change adds some conditions allowing us to skip importing this file in .NET Core projects.
There are two parts to this fix:
Bugs this fixes:
dotnet/project-system#1474 and dotnet/project-system#1508
Risk
Low. The risk may come from us accidentally depending on properties defined in Microsoft.NuGet.targets but all relevant properties have already been copied over to our targets. Furthermore the CLI has been operating without a dependency on this for some time so this ensures parity between the VS and CLI experience.
Performance impact
None
Is this a regression from a previous update?
No
How was the bug found?
Dogfooding
/cc @srivatsn @dsplaisted @nguerrera