-
Notifications
You must be signed in to change notification settings - Fork 258
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
[DCR]: Issues with new NU1507 warning #11822
Comments
I am hitting this problem, however even turning off warnings as errors and suppressing NU1507 it still throws the error and blocks compilation. Has anyone found a solution to this? |
For me, using |
I will try that, but adding NoWarn in every project has not worked for me, it still throws... The problem isn't during the build but during the nuget restore, it seems. |
And just to make it clear: I am most definitely not saying there is no problem here. I'd still call it broken by design given that there are 2 package sources present in a clean SDK install, meaning NU1507 always pops up in a clean CI build: \path\to\foo.csproj : warning NU1507: There are 2 package sources defined in your configuration. When using central package management, please map your package sources with package source mapping (https://aka.ms/nuget-package-source-mapping) or specify a single package source. The following sources are defined: https://api.nuget.org/v3/index.json, C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\ |
You should be able to add this to your <PropertyGroup>
<NoWarn>$(NoWarn);NU1507</NoWarn>
</PropertyGroup> We are working with the .NET SDK folks to see how we can get the fallback folder (C:\Program Files (x86)\Microsoft SDKs\NuGetPackages) configured in such a way that it works with package source mapping. |
An important element on the nuget side is surfacing a command-line way of adding package mappings. Right now, our CI environment creates a blank nuget config with |
So just a followup, on my local machine using the nowarn worked, but then when I went to build remotely (build pipeline) that failed. So I am now in a situation where there is no solution I can find to build both locally and remotely. So I have to put the nowarn commented out in the directory.build.props, and uncomment when building locally, then comment out again before checking in. This is clearly not ideal, when do we expect this behavior to be consistent between local builds and pipeline builds? |
It seems odd that the presence of a If the failure is "NU1507 not known" (because the pipeline uses an older sdk) then you should be able to add a (But if the pipeline uses an older sdk, perhaps you should consider using a global.json to specify the use of that exact same sdk for local development as well.) |
That is exactly what I thought, then had to say to my team that had to redo their approvals on my PR since I had to update it without the no warn. Just to be clear here is exactly what happened in order:
Error:
|
Something I realized recently is that |
Thanks for all of this feedback. I believe we've addressed everything in this issue and wanted to see if everyone agrees:
NuGet's central package management has always been considered in "preview" so we felt comfortable adding a new warning and fully acknowledge that a warning treated as an error is a breaking change. We'll be removing the "preview" tag from this feature in the next release and will refrain from adding new warnings going forward.
I have added documentation around the warning, NU1507, here. It should clear up why package source mapping is important and points to more documentation on package source mapping. I've also changed the warning logic to ignore non-HTTP sources which should help when the .NET SDK injects local sources.
There is an official tool for onboarding to Package Source Mapping available here: https://github.com/NuGet/PackageSourceMapper. There are also pointers to this tool in the official documentation.
This work is tracked here: #10735. There's a decent amount of discussion on this issue, do you feel I've covered it all and can close this issue for now? |
I'll have to give this a good read to be able to confirm. My main concern is that #10735 essentially went inactive after this ticket was created. If the intent is to actively rekindle that work after this ticket is closed, then great. Otherwise, I worry that nothing will happen after closing this ticket. |
As for Visual Studio 17.4 the warning has been updated to only look at remote feeds and feeds added by the .NET SDK like |
NuGet Product(s) Affected
MSBuild.exe, dotnet.exe
Current Behavior
With the VS 2022 17.2 (.NET SDK 6.0.300) release, a change has been introduced in the handling of CentralPackageVersionManagement: if there are multiple package sources defined, a new warning,
NU1507
, is issued.Note: the current nuget.exe (6.1.0) does not issue this warning (but I'm assuming the next version will?).
This warning is documented in https://docs.microsoft.com/en-us/nuget/consume-packages/central-package-management#warning-when-using-multiple-package-sources
Where the problems start is:
following points, apparently for no real reason)
something break if each package does not resolve to exactly one source?
NU1507
toNoWarn
is safe, or likely tobreak things down the line
Desired Behavior
That depends on the reason for NU1507; if it's only a recommendation or best practice, then at a minimum it should be documented as such, potentially explicitly mentioning that it's safe to disable the warning, or that it can be avoided by mapping all sources to the "*" pattern. (But my absolute preference would be to drop it, or only issue it as part of some new "nuget analyze-config" command.)
If there's actual potential for breakage when multiple potential sources apply to a package, then that should be clearly documented (and perhaps briefly explained in the warning as well). And then a situation where the nuget.config specifies overlapping mapping patterns should likely trigger NU1507 too. Ideally, there would also be some sort of description of how to handle some relatively common scenarios, like having one "real" nuget feed (say, nuget.org), plus one local folder source (to make it easy to do testing with locally-built test packages). In such a case, there may not always be a usable prefix pattern, so using "*" for both would be reasonable.
Additional Context
No response
The text was updated successfully, but these errors were encountered: