Is there any reason why MSBuild is not located from within LinqPad?
async Task Main() { if (!MSBuildLocator.IsRegistered) { MSBuildLocator.RegisterDefaults(); } using (var w = MSBuildWorkspace.Create()) { var sln = await w.OpenSolutionAsync(@"..."); } }
MSBuildLocator.RegisterDefaults();
throws
InvalidOperationException: No instances of MSBuild could be detected.
Try calling RegisterInstance or RegisterMSBuildPath to manually register one.
Yet running same code as console application works fine.
Comments
I can't think of why that wouldn't work - it works for me when I add a package reference to Microsoft.Build.Locator.
I found the reason.
It looks like VS update removed SDK for .NET 7 and installed SDK for .NET 8
I am running LinqPad 7. When I installed .NET 7 SDK it started working.
Thanks.
Thanks for the update. I've also experienced a .NET installation disappearing while in use, usually manifesting as file-not-found errors when running a query.