-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
MSBuildWorkspace.OpenProjectAsync fails when dotnet is not pre-installed in the system #77640
Comments
@framar-RA: just trying to understand your scenario a bit more here, is the expectation that:
If it's the former we should see why it's thinking you need to analyze an SDK-style project; if it's the latter then that's definitely not good.
If you're already running under dotnet.exe I'd expect that to work since there's some obscure logic in the .NET runtime which will use the dotnet.exe you're in if your process is dotnet.exe itself. Otherwise this could be a potential dupe of #71019 if that's ultimately what we're not doing right. |
The latter scenario describe pretty well the context in which we operate. In particular we have a private dotnet which is not on the PATH.
I am working to provide you with more precise information about this. For the moment I can tell you that C# handler is build as a dll and the methods are exposed with COM (to the main c++ app). |
@framar-RA Is it still a dotnet.exe process or something running as a custom app host? |
@jasonmalinowski Sorry for the late reply. As a personal note, I must admit I have limited knowledge about the COM interop process and the part of our codebase responsible for these operations. Sadly, filling this gap is taking more time than expected. That said, I cannot confidently answer your question, but I can give you some insight into the minimal working example we failed to set up to reproduce the issue, which may shed some light on the situation. In particular, we tried to define a C# handler using Roslyn on a VM without .NET installed. This setup mimics the one of our app WITHOUT the need to rely on interop (i.e., the main app is a C# handler, thus compiled and run with dotnet.exe).
As expected, we were not able to reproduce the error this way since we ran the handler using the dotnet.exe distributed within the example. As you suggested, the .NET runtime is capable of "detecting" the dotnet.exe of the process being launched. Moreover, a quick check revealed that during the execution of the C# handler in our main app (not the example), only one dotnet process is active, which is the following:
If we were running as a dotnet.exe process, I was expecting to see a similar process launching one of our DLLs, but this is not present. |
Version Used:
.NET: 8.0
sdk: 8.0.406
Microsoft.CodeAnalysis.CSharp.Workspaces: 4.12.0
Microsoft.CodeAnalysis.Workspaces.MSBuild: 4.12.0
Microsoft.Build: 17.8.3
Microsoft.Build.Locator: 1.6.10
Description:
We encountered a problem that prevents us from upgrading the NuGet dependencies of our project (specifically Microsoft.CodeAnalysis.CSharp.Workspaces and Microsoft.CodeAnalysis.Workspaces.MSBuild) from version 4.7 to 4.12.
We have a C++ project that we distribute along with .NET. The main app communicates with a C# handler, which tries to open and analyze an external C# project by executing the following lines of code:
Upgrading the aforementioned NuGet packages from version 4.7 to version 4.12 causes the function call OpenProjectAsync to fail if our application is installed on systems where .NET is not preinstalled.
Steps to Reproduce:
Despite being unable to reproduce this problem with a minimal working example, we managed to reproduce this issue in a VM with Windows 10. We analyzed the differences between the two versions of the NuGet packages by connecting a remote debugger to our running application. Specifically, these additional lines of code were not present in version 4.7 but can be found in version 4.12 of
Microsoft.CodeAnalysis.Workspaces.MSBuild
.Starting the BuildHostProcess (.NET Core) causes the error: the dotnet executable seems to be launched from the working directory
""
, (from the debugger we seeprocessStartInfo.workingDirectory = ""
), which, in general, may not containdotnet.exe
. As a consequence, the PATH environment variable is used. It would be nice to have a way to specify where to look fordotnet.exe
to prevent this issue from occurring when .NET is not installed on the system.Expected Behavior:
No exception is thrown. The function call succeeds.
Actual Behavior:
An exception is thrown:
Additional Note:
The text was updated successfully, but these errors were encountered: