dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.02k stars 4.03k forks source link

Opening solution containing projects with non-solution configurations. #6709

Open PaulEremeeff opened 8 years ago

PaulEremeeff commented 8 years ago

Let's take a solution containing a single Debug configuration. Let's add two projects to this solution - App1 and Library1. Now, App1 contains DebugApp configuration, Library1 contains DebugLibrary configuration and the solution is set to build these configurations on its' Debug configuration. App1 contains a reference to Library1 and utilizes some of the types declared there.

When I open this solution through MSBuildWorkSpace.OpenSolutionAsync() method, and then get Compilation objects for each project, I get compilation errors in App1 compilation about types declared in Library1.

The problem is, it is impossible to open the whole solution with correct configuration for each of these two projects, as I can only specify a single Configuration|%Name% pair when creating the MSBuildWorkSpace.

It is possible to open each project in a separate workspace, passing the correct configuration to each one, but then one project references another one, as in the case of App1 and Library1, I still get the compilation errors, as Library1 does not have DegubApp configuration and vice versa.

We've created a workaround for this by opening each project separately and then adding them to a single solution through AddProject mthod, but this seems unreliable (for example, we had to rearrenge project references for each project as when opened in a separate workspace it will have a different GUID id from another workspace) and it takes a lot longer then just using OpenSolutionAsync method, as each project opened in a separate workspace also loads all of its' dependencies (with possible incorrect configurations).

Droni commented 6 years ago

You can't fix this issue more than two years...