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

Roslyn crashes when opening a project without Visual Studio version 2017 or higher installed on a machine #75886

Open
NikiPn opened this issue Nov 13, 2024 · 0 comments
Labels
Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@NikiPn
Copy link

NikiPn commented Nov 13, 2024

Version Used:
4.13.0-2.24561.4

Steps to Reproduce:

  1. Create a console application and add packages, 'Microsoft.CodeAnalysis' and 'Microsoft.CodeAnalysis.Workspaces.MSBuild' (version 4.13.0-2.24561.4).
    The project file will be as follows:
<Project Sdk="Microsoft.NET.Sdk">
 
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net472</TargetFramework>
  </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="Microsoft.CodeAnalysis" Version="4.13.0-2.24561.4" />
        <PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.13.0-2.24561.4" />
  </ItemGroup>
 
</Project>
  1. Add this code fragment to the 'Main' method:
var workspace = MSBuildWorkspace.Create();
_ = workspace.OpenSolutionAsync("D:\\ MySolution.sln").Result;
  1. Create a console app in a project templates for Visual Studio 2015. Open the project using the program created above.

Expected Behavior:
No exception.

Actual Behavior:
Exception is thrown:

Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.ComponentModel.Win32Exception: The system cannot find the file specified
  at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
  at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
  at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.<GetBuildHostAsync>d__9.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.<GetBuildHostWithFallbackAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
....

Note: We would like to note that this issue is critical for us. We would be grateful if you could assist us in fixing it. Furthermore, we would deeply appreciate it if you could tell us if there are any known possible workarounds.

This information may help you: MSBuildLocator can successfully register MSBuild for Visual Studio 2015.

MSBuildLocator.RegisterMSBuildPath(@"C:\Program Files (x86)\MSBuild\14.0\Bin"); 
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead labels Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

1 participant