-
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: Loading a solution with a ProjectReference prevents compilation #36072
Comments
Using Procmon, I believe it is reading the Microsoft.Build.Tasks.Core assembly from C:\Program Files\dotnet\sdk\2.1.602\Microsoft.Build.Tasks.Core.dll. Interestingly, when I decompile this with ILSpy, I find that the ResolveNonMSBuildProjectOutput class does not exist - I suspect this is the root of my problem. The version of the DLL is 15.1.0.0 but the assembly file version is 16.0.450.56488. I have older versions of 15.1.0.0 of this DLL on my machine (e.g 15.1.1012.6693) that do have this class in place. EDIT |
I've discovered that if I change the TargetFramework of RoslynTest project to net472, rather than netcoreapp2.1 it works. I've posted this as a Stack Overflow question as well: |
Running into this exact behaviour as well - Is there any updates on it? Thanks! |
This comment maca88/AsyncGenerator#24 (comment) suggests setting However, if I create a workspace like this var workspace = MSBuildWorkspace.Create(new Dictionary<string, string>() {
{ "BuildingInsideVisualStudio", "false" }
}); I'm running into the following exception
|
@daniel-munch-cko Same here. I even tried overriding default properties with reflection, but it still fails to build with the following message: The "ResolvePackageAssets" task failed unexpectedly. System.IO.FileLoadException: Could not load file or assembly 'NuGet.Frameworks, Version=4.9.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621) I really need this functionality... If anyone finds a workaround, please post it here. |
On my Mac I ended up using |
Unfortunately, my application targets Core and I can't use Now I'm more interested to know if this issue is solvable at all or is it a dead-end. |
I see, yeah that's indeed a terrible workaround. My next attempt would have been to file a similar issue (or to link this issue) in the That's without evidence, but the error message seems to suggest troubles in locating an assembly, which is exactly what the |
It's my understanding that |
What led me to this report - I was trying to build (netcore) console analyzer for another netcore project. At least it was easy to switch the analyzer to 4.7.2. Whatever SDK MSBuildLocator locates should be able to work in that scenario... |
@daniel-munch-cko I ported my console app to net472 and while executing it on Mono I get Did you encounter anything similar? |
Same problem here. I'm trying to build .NET core app that runs analysis on a non-core .NET app. It's a unity project, so can't just change that -- unity generates a sln and csproj's. If I run the exact same code as a .NET 4.7 console app, it works fine. Would love to hear from someone whether the scenario I am going for is even supported or if this is a legitimate bug. |
Sorry @ionoy realised I forgot to reply - I think I saw something similar, I explicitly registered the Mono MSBuild path using this line MSBuildLocator.RegisterMSBuildPath("/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/msbuild/15.0/bin/"); |
@daniel-munch-cko I did that too, but it didn't help. There was a new error on constructing |
I think I ran into the same issue with |
This is what I don't like about that approach. It's slightly odd to me that compiling a .NET Core project such a hassle. Is this really an unsupported use case, or does anyone have an example? |
I've also faced the same issue trying to load |
@InfinitiesLoop No, that's not a supported scenario. .NET Core MSBuild doesn't support every operation that full .NET Framework As a result of that, some projects can only be built with full framework MSBuild, so an application that wants to use the MSBuild API for them (including indirectly through @d-dizhevsky Looking through this thread, I see several related issues. Can you be explicit about what problem you have? |
@rainersigwald It contains:
The Please note that if you remove |
@d-dizhevsky Thanks! I opened dotnet/msbuild#4770 to track fixing that problem. Setting |
I have similar problem - I have .net framework application which tries to open a .net core project using msbuild api (to later use roslyn analysis). Opened project contains error diagnostics. What's interesting, if I run Debug>Run Debugging, the problems disappear. I filed a bug for msbuild, but maybe this is more roslyn related? |
== Emphasis for MS devs before wall-of-text manual workaround: there's a manual workaround, but this bug is NOT user error and likely affects a significant number of .net core deployments using Roslyn. It LIKELY either has to do with a mix of VS deployment version & MSBuild loading an old .NET Core SDK. The bug likely manifests in many other ways. For example, it caused my Roslyn setup to fail to resolve I found a manual workaround to this WorkspaceFailed error:
There were a few resolution steps:
Success! This error was gone, but running my roslyn app then resulted in some error like (paths stripped)
Solved this one by adding NuGet.ProjectModel 5.5.1 to my project, the csproj now has the following package references:
No more WorkspaceFailed events for this code:
My csproj looks as follows:
|
See dotnet/roslyn#36072 (comment) MSBuild had a bug which made Roslyn unable to successfully load projects. This led to Roslyn being unable to resolve types like `float` to sdk framework assemblies.
This is a result of microsoft/MSBuildLocator#86, so we should be able to avoid the need for that reference. |
Version Used:
Microsoft.Build.Locator v1.2.2
Microsoft.CodeAnalysis v3.1.0
Microsoft.CodeAnalysis.Workspaces.MSBuild v3.1.0
Steps to Reproduce:
See attached "RoslynTest.zip" for Zip file demonstrating problem. Unzip to C:\Source (or modify the code to point to correct location) and run RoslynTest.sln
RoslynTest.zip
Expected Behavior:
Both projects compile with 0 errors.
Actual Behavior:
Project B fails to compile. In addition, project B reports that it has 0 Metadata references (whereas it has 113 without the PackageReference)
In particular, I note the following output reported:
The text was updated successfully, but these errors were encountered: