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

MSBuildSdkResolver throws ArgumentException when solution path is an empty string #24320

Closed
jeffkl opened this issue Mar 10, 2022 · 1 comment · Fixed by #24333
Closed

MSBuildSdkResolver throws ArgumentException when solution path is an empty string #24320

jeffkl opened this issue Mar 10, 2022 · 1 comment · Fixed by #24333
Assignees
Labels
Area-SdkResolvers Bug untriaged Request triage from a team member

Comments

@jeffkl
Copy link
Contributor

jeffkl commented Mar 10, 2022

Describe the bug

Reported as part of dotnet/msbuild#7453

When an MSBuild project SDK is being resolved in some cases (ie Visual Studio), the SdkResolverContext has an empty string for the solution path. The MSBuildSdkResolver tries to call Path.GetDirectoryName() on an empty string and an ArgumentException is thrown. The code is trying to fall back to using the project path but is only checking for null, not an empty string.

image

image

string globalJsonStartDir = Path.GetDirectoryName(context.SolutionFilePath ?? context.ProjectFilePath);

To Reproduce

Evalute an MSBuild project file with a solution path as an empty string.

Exceptions (if any)

Further technical details

  • Include the output of dotnet --info
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Mar 10, 2022
@jeffkl jeffkl changed the title MSBuildSdkResolver throws ArgumentNullException when solution path is an empty string MSBuildSdkResolver throws ArgumentException when solution path is an empty string Mar 10, 2022
@jeffkl
Copy link
Contributor Author

jeffkl commented Mar 21, 2022

Fixed by #24333

@jeffkl jeffkl closed this as completed Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-SdkResolvers Bug untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants