microsoft / MSBuildLocator

An API to locate MSBuild assemblies from an installed Visual Studio location. Use this to ensure that calling the MSBuild API will use the same toolset that a build from Visual Studio or msbuild.exe would.
Other
212 stars 83 forks source link

Regression in v1.5.3 - The SDK 'Microsoft.NET.Sdk' specified could not be found. #181

Closed kamronbatman closed 10 months ago

kamronbatman commented 1 year ago

I updated our dependency in this project from 1.4.1 to 1.5.3: https://github.com/modernuo/SerializationGenerator/tree/main/ModernUO.Serialization.SchemaGenerator and now I am getting the error The SDK 'Microsoft.NET.Sdk' specified could not be found.

I have the VS2022 and 6.0.400 SDK installed. I do not have .NET 7 preview installed.

EDIT: Now I have a weird issue. I decided to not update this package and leave it at 1.4.1. But I did update WorkSpaces to 4.3.0. And it seems to also be broken, but only when I use the nuget package I built, not in the IDE (either VS or Rider).

This is super weird and a new problem. I am going to try and revert back to workspaces v4.2.0 and see if that fixes it.

EDIT 2: It looks like reverting to msbuildlocator 1.4.1 and workspaces 4.2.0 fixed it. So I am not sure if this is even an issue with this package. I would love some advisement since I am a little lost tracking it all.

Also to note: MSBuildLocator 1.5.3 and Workspaces 4.2.0/4.3.0 do not work. And with Workspaces 4.3.0, MacOS 11 gets a hostfx native image error while trying to find the SDK, which I think is a separate issue, but relevant to my testing since I test on a variety of operating systems.

Forgind commented 1 year ago

Failing to find the SDK sounds like either an MSBuild bug or an SDK bug, as MSBuild owns the general process of SDK resolution, and the SDK owns the SDK resolver that should work in this case. I think Roslyn owns the MSBuildWorkspace, though I'm not sure about that.

The hostfxr bug is very plausibly an MSBuildLocator issue, though. Do you have a path to your dotnet executable on the PATH? And is there another (earlier) folder on your PATH that has either a bad executable or a symlink that looks reasonable but actually doesn't point to a file that exists? One of my recent (unmerged) PRs is trying to fix the latter problem.

Forgind commented 1 year ago

I'd also check out https://github.com/microsoft/MSBuildLocator/issues/68#issuecomment-1384609721, as that might be the issue.

kamronbatman commented 1 year ago

I have wiped my MacOS since this issue. I'll do a clean setup with .net 7 and bump dependencies and see if I get the issue. I think #68 might be related but for a different reason since this is OSX.

YuliiaKovalova commented 10 months ago

The issue is fixed. Pending release.