Skip to content
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

MSBuild NuGet SDK Resolver fails to locate global.json file in Visual Studio project folder #11747

Closed
sae42 opened this issue Apr 14, 2022 · 2 comments
Assignees
Labels
Functionality:Restore Product:MSBuildSDKResolver The NuGet powered SDK resolver. Owned by MSBuild team Resolution:ByDesign This issue appears to be ByDesign Type:Bug
Milestone

Comments

@sae42
Copy link

sae42 commented Apr 14, 2022

NuGet Product Used

dotnet.exe, MSBuild.exe

Product Version

Visual Studio 2022 17.2 Preview 3

Worked before?

Visual Studio 2022 17.1 and earlier

Impact

It's more difficult to complete my work

Repro Steps & Context

The issue is a dotnet CLI template which contains a global.json file (in my case referencing a project SDK) which is then also used via the Visual Studio new project dialog. So the global.json file is in the same directory as the project, but in the Visual Studio case the default creation case is to create a solution folder and a project sub-folder. The project sub-folder contains the global.json file in this case. The MSBuild NuGet SDK Resolver fails to locate the global.json file in the project folder.

The issue was trigger by this #4380 I believe. There was a subsequent bug and a change with this #4507.

That secondary change almost fixes the issue for me, but unfortunately it does not handle the case when the resolver context defines both a solution and project. The existing code means the solution always wins even if the project is set. The consequence is that a global.json in the project folder is not found. I believe a change to check the project file path context first would resolve this problem.

Verbose Logs

No response

@sae42 sae42 changed the title [Bug]: MSBuild NuGet SDK Resolver fails to locate global.json file in Visual Studio project folder Apr 14, 2022
@jeffkl
Copy link
Contributor

jeffkl commented Apr 14, 2022

At this time this is by design. The .NET SDK resolver has always respected the solution path over the project path and we wanted to make the NuGet-based MSBuild project SDK resolver consistent.

https://github.com/dotnet/sdk/blob/1c817a47346f4db67ce3463cad7f60b54bfe122f/src/Resolvers/Microsoft.DotNet.MSBuildSdkResolver/MSBuildSdkResolver.cs#L91

Its only supported to have one global.json in the repository and it should be in the root if possible as a best practice. Perhaps we need to update the CLI template to take this into account.

@jeffkl jeffkl added Resolution:ByDesign This issue appears to be ByDesign Functionality:Restore Product:MSBuildSDKResolver The NuGet powered SDK resolver. Owned by MSBuild team and removed Triage:Untriaged labels Apr 14, 2022
@jeffkl jeffkl self-assigned this Apr 14, 2022
@nkolev92
Copy link
Member

Team Triage; Closing per @jeffkl's comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:Restore Product:MSBuildSDKResolver The NuGet powered SDK resolver. Owned by MSBuild team Resolution:ByDesign This issue appears to be ByDesign Type:Bug
Projects
None yet
Development

No branches or pull requests

3 participants