dotnet/roslyn

Opening solution containing projects with non-solution configurations.

Open

#6709 aperta il 11 nov 2015

Vedi su GitHub
 (1 commento) (2 reazioni) (0 assegnatari)C# (4257 fork)batch import
Area-IDEConcept-APIFeature RequestIDE-MSBuildWorkspacehelp wanted

Metriche repository

Star
 (20.414 star)
Metriche merge PR
 (Merge medio 6g 17h) (256 PR mergiate in 30 g)

Descrizione

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).

Guida contributor