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

VS 2022 can't find .NET Framework build host after update #73854

Closed
vsfeedback opened this issue Mar 8, 2024 · 17 comments · Fixed by #76747
Closed

VS 2022 can't find .NET Framework build host after update #73854

vsfeedback opened this issue Mar 8, 2024 · 17 comments · Fixed by #76747
Assignees
Milestone

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:It’s more difficult to complete my work]
I have an exception in VS 2022 after fresh update from 17.7.1 to 17.9.2. The exception is thrown in my VS add-on by execute following code

var service = (DTE2) Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SDTE));
using (var workspace = MSBuildWorkspace.Create())
{
    var solution = workspace. OpenSolutionAsync(service. Solution.FileName). Result;

}

System.AggregateException: One or more errors occurred. —> System.InvalidOperationException: Unable to locate the .NET Framework build host at c:\program files\microsoft visual studio\2022\enterprise\common7\ide\commonextensions\microsoft\vbcsharp\languageservices\BuildHost-net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.exe - line 206
at Roslyn.Utilities.Contract.Fail(String message, Int32 lineNumber)
at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.GetPathToDotNetFrameworkBuildHost()
at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.CreateDotNetFrameworkBuildHostStartInfo()
at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager. d__8.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager. d__7.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker. d__20.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker. d__21.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker. d__19.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader. d__22.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader. d__22.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace. d__24.MoveNext()
— End of inner exception stack trace —
at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at CallsLogger.ExceptionWrapper.ChangeSources(AsyncPackage package, Func3 action)
—> (Inner Exception #0) System.InvalidOperationException: Unable to locate the .NET Framework build host at c:\program files\microsoft visual studio\2022\enterprise\common7\ide\commonextensions\microsoft\vbcsharp\languageservices\BuildHost-net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.exe - line 206
at Roslyn.Utilities.Contract.Fail(String message, Int32 lineNumber)
at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.GetPathToDotNetFrameworkBuildHost()
at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.CreateDotNetFrameworkBuildHostStartInfo()
at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager. d__8.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager. d__7.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker. d__20.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker. d__21.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker. d__19.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader. d__22.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader. d__22.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace. d__24.MoveNext()<—


Original Comments

Feedback Bot on 3/4/2024, 09:19 PM:

(private comment, text removed)


Original Solutions

(no solutions)

@falpizar
Copy link

falpizar commented Mar 8, 2024

Found same issue after upgrade.
Also needed to process .net 7 projects but fails:

File: MSBuildProjectLoader.cs
Class: Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.worker
Method: LoadProjectFileInfosAsync

'buildHost' gets null value:

RemoteBuildHost buildHost = (await _buildHostProcessManager.GetBuildHostAsync(projectPath2, cancellationToken..)).Item1;

@CyrusNajmabadi
Copy link
Member

@JoeRobich do you have any ideas here while @jasonmalinowski is oof?

     -- Cyrus

@JoeRobich
Copy link
Member

TIL I learned we shipped Workspaces.MSBuild in VS. Seems like a setup authoring issue with the managed languages VS component. We are only shipping one version of the BuildHost and in the wrong folder.

Image

@Metalaka
Copy link

Metalaka commented Apr 8, 2024

Hi, any news on this issue ?
extensions on VS 17.9 and 17.10 preview are unable to use MSBuildWorkspace

@tshaug
Copy link

tshaug commented Apr 17, 2024

Hi everybody,

is there any workaround available to mitigate this issue (e.g. copying required exe and ddls into the "right" directory"?). At the moment I am stuck.
Thank you very much! Thomas

@Metalaka
Copy link

Metalaka commented May 16, 2024

Hello @CyrusNajmabadi,
it seems that the contentFiles added in Microsoft.CodeAnalysis.Workspaces.MSBuild v4.9 by #70469 is not correctly shipped by the VS installer.

The nuget Microsoft.CodeAnalysis.Workspaces.MSBuild @ 4.9.0-3.final is deployed in C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\CommonExtensions\Microsoft\VBCSharp\LanguageServices but the contentFiles is missing. If I manually copy the folder BuildHost-net472 and BuildHost-netcore from the nuget to the VS installation folder my extension works fine.

Can anyone investigate why the contentFiles is missing or maybe transfert the issue to the VS team ?
Thanks

@erchauvet
Copy link

erchauvet commented May 30, 2024

Bonjour je rencontrais le même problème que vous avec vs2022 (17.10.1)
mon ancien code
_solution.GetSolutionInfo(out string solutionDirectory, out string solutionFile, out string solutionOptions);

/*
using (var workspace = Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.Create())
{
JoinableTaskFactory.Run(async delegate
{
_roslynSolution = await workspace.OpenSolutionAsync(solutionFile);
});
}
*/

mon nouveau code
var componentModel = (IComponentModel)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SComponentModel));
var WSworkspace = componentModel.GetService<Microsoft.VisualStudio.LanguageServices.VisualStudioWorkspace>();

_roslynSolution = WSworkspace.CurrentSolution;

en esperant que cela puisse vous débloquer aussi

Cdt
Eric

@tshaug
Copy link

tshaug commented Jun 4, 2024

@erchauvet Thanks for providing your code snippet. It solves my problem :-)

@jasonmalinowski
Copy link
Member

So for folks who are trying to use MSBuildWorkspace to analyze the currently open solution -- you should not be using MSBuildWorkspace in that situation -- @erchauvet's code snippet is what you should be doing the VisualStudioWorkspace represents the current open solution, and will be vastly faster to use, since that's the same snapshot we're driving many features with.

If you're using it to analyze some other solution, then we'll still get this fixed, but this hopefully gets you in the right direction in a lot of cases.

@jasonmalinowski jasonmalinowski transferred this issue from dotnet/roslyn-analyzers Jun 5, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead labels Jun 5, 2024
@dibarbet dibarbet removed the untriaged Issues and PRs which have not yet been triaged by a lead label Jun 17, 2024
@dibarbet dibarbet added this to the 17.12 milestone Jun 17, 2024
@risperdal
Copy link

Same problem

1 similar comment
@testirme
Copy link

Same problem

@risperdal
Copy link

I guess the problem is related to updated version of Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace package.
If i downgrade that package to 4.7.0 it still works

@tobyash86
Copy link

This issue is a critical issue blocking my customers. Will the solution be provided before the official .NET 9 release?

@cirrusqm
Copy link

cirrusqm commented Dec 3, 2024

This is a problem for us after upgrading to Visual Studio 17.12.2. The workarounds have not been helpful since our program loads other standalone projects for analysis. Please fix!

@tobyash86
Copy link

Is anything happening around this issue? All tools that use Roslyn outside of Visual Studio are blocked. Is there any official Microsoft statement about it?

jasonmalinowski added a commit that referenced this issue Jan 22, 2025
Without this, Microsoft.CodeAnalysis.Workspaces.MSBuild.dll itself is
deployed, but will fail to work since it can't find any build hosts
deployed alongside the DLL.

Fixes #73854
jasonmalinowski added a commit that referenced this issue Jan 22, 2025
Without this, Microsoft.CodeAnalysis.Workspaces.MSBuild.dll itself is
deployed, but will fail to work since it can't find any build hosts
deployed alongside the DLL.

Fixes #73854
@jasonmalinowski
Copy link
Member

Fix is merged for 17.14 and 17.13; it's not in 17.13 Preview 3 (which shipped today), but expecting it to be in Preview 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.