Buildalyzer
Buildalyzer copied to clipboard
method AnalyzerResultExtension.AddToWorkspace doesn't check for duplicate projects in solution
Consider the following snippet.
analyzerResult = projAnalyzer.Build();
…
analyzerResult.AddToWorkspace(workspace, true);
Now, assume that the project to which the object projAnalyzer
is associated with has structure such as that of this project — from a Roslyn issue.
Then, the addition to the workspace triggers an InvalidOperationException
. I imagine that Buildalyzer should check the presence of the project before adding it (due to transitive references).
I'm having a little trouble understanding the issue here. Can you provide any more details about the InvalidOperationException
generated in this case? Is it coming from Buildalyzer directly (and if so, where?) or from Roslyn?
What would really help is a reproducible Solution and Project file(s) so I can see exactly what's going on.
The InvalidOperationException
is generated from MSBuild API, but it does so because Buildalyzer adds duplicate Project
s to a Solution
/Workspace
.
You can reproduce this issue by creating .csproj
files that map the organization I mentioned here, requesting their corresponding ProjectAnalyzers
to build and passing true
as the option to (automatically) include project references.
I just did some related work on transitive references in Roslyn workspaces in #181 which should hopefully help with the scenario here, but I still can't reproduce anything like the InvalidOperationException
you describe. Any chance you could work up a small reproducible project with the latest version that exhibits this problem? This might be a good starting point: https://github.com/slang25/BuildalyzerBugRepro
Any chance you could work up a small reproducible project with the latest version that exhibits this problem?
@daveaglick the project I describe here reproduces the issue I mention.