-
Notifications
You must be signed in to change notification settings - Fork 83
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
Version 1.5.3 misses a trailing directory separator path #176
Comments
dotNetSdkPath may not end with / or \ - we can't concat
Just in case it helps anyone else, I got stuck on this for a good chunk of the day as this was the error I was presented which was misleading:
I would recommend that in addition to fixing the missing directory separator, that a bugfix also includes checks to ensure that the directories exist so that a more meaningful error message can be shown as this error message was not very helpful. |
I can also confirm this issue. Problem is that at this place a simple concatination is done instead of using MSBuildLocator/src/MSBuildLocator/MSBuildLocator.cs Lines 311 to 322 in 850d27b
|
…Build locator due to bug microsoft/MSBuildLocator#176
…or#176) Improved logging and exception handling
Lost a full day of work to figuring this out after Microsoft.Build and Microsoft.CodeAnalysis started spewing "SDK not found" errors :( I also considered a reflection hack as an interim workaround like MarkPflug above, but it turned out to be simpler to just wipe the offending environment variables after calling RegisterDefaults. Works for my build, but no idea if it has other implications.
Downgrading Microsoft.Build.Locator nuget back to 1.4.1 also appears to work (on .net 6.0.4, Microsoft.Build 17.3.1, Microsoft.CodeAnalysis 4.2). |
Fixes #176 As descibed in the issue it seems there are no trailing backslashes in some paths. To ensure proper paths in the environment variables I changed the string concatenation to a safer Path.Combine
In a project, where the MS Build instance is registered with
MSBuildLocator.RegisterDefaults();
before calling a method that ends up doing:Both the above and doing just
new Project("path");
fails with anInvalidProjectFileException
.Looking at the
ProjectCollection
, the difference between Microsoft.Build.Locator 1.4.1 and 1.5.3 is inProjectCollection.Toolsets[0]._properties[0]
.1.4.1:
"MSBuildSDKsPath"="C:\\Program Files\\dotnet\\sdk\\6.0.303\\Sdks"
1.5.3:
"MSBuildSDKsPath"="C:\\Program Files\\dotnet\\sdk\\6.0.303Sdks"
This might need to be fixed in the
Microsoft.Build.Evaluation
package instead of here, though.The text was updated successfully, but these errors were encountered: