NuGet / Home

Repo for NuGet Client issues
Other
1.49k stars 250 forks source link

[Bug]: nuget.config next to .sln is only applied to csproj's rooted under .sln #12146

Open hknielsen opened 1 year ago

hknielsen commented 1 year ago

NuGet Product Used

dotnet.exe, MSBuild.exe, NuGet.exe

Product Version

nuget

Worked before?

No response

Impact

It's more difficult to complete my work

Repro Steps & Context

nuget.config next to solution only applies to .csproj's thats under the subfolders from the solution. If a .csproj that is placed with a seperate root is added to the solution, that will not pick up the same nuget.config.

/slnroot/Some.sln /slnroot/nuget.config /slnroot/Foo/Foo.csproj - includes the nuget.config /seperateRoot/Bar/Bar.csproj - Does not include the nuget.config from /slnroot/nuget.config

https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior Does say subfolders, but when its next to a Solution, and the Scope are Solution, I would expect it to work.

Verbose Logs

No response

hknielsen commented 1 year ago

@jeffkl If you have any thoughts? Happy to create a PR, it if makes sense

nkolev92 commented 1 year ago

Team Triage: NuGet and other build components such as the SDK, tend to look from the project up, starting with the project directory in question.

It is expected that the global.json, nuget.config and the like files are in the same rooted parent directory.

We need to update the docs to call this out.

hknielsen commented 1 year ago

Hi @nkolev92, global.json looks at the SolutionPath first, and then ProjectPath second. https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/Microsoft.Build.NuGetSdkResolver/GlobalJsonReader.cs#L100

nuget.config "Solution Scope" is not really Solution Scope, it seem like its working like Directory.Build.props/targets. Right now im forced to install a User wide nuget config file, and everybody that uses the project, because its not Solution scoped