Description
I've debugged this quite a bit and the problem is simple. But I'm not sure if I need to take it up here or somewhere in the dotnet repos.
Minimal repro is simple.
- New solution
- New WPF (netcore) project
- New Test project (added coverlet.msbuild too)
- Create directory.build.props in the solution folder.
<Project>
<PropertyGroup>
<SolutionDir>$(MSBuildThisFileDirectory)</SolutionDir>
<BaseIntermediateOutputPath>$(SolutionDir)bin\obj\$(Configuration)\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
<!-- or -->
<!--<IntermediateOutputPath>$(SolutionDir)bin\obj\$(Configuration)\$(MSBuildProjectName)\</IntermediateOutputPath> -->
</PropertyGroup>
</Project>
Commands and whether it instrumented correctly.
❌ > dotnet test /p:CollectCoverage=true
❌ > dotnet test --collect "XPlat Code Coverage"
-> fails
✔️ > dotnet test --collect "Code Coverage"
-> works
I built coverlet.msbuild and set my environment flag to let me debug.
The problem occurs in Instrumenter.cs:L151.
It fails when it tries to verify that App.xaml and MainWindow.xaml exist. (any .xaml file I think)
In builds where $([Base]IntermediateOutput)
is not set, the PE metadata indicates the source document will be at:
....\<SolutionDir>\WpfApp1\App.xaml
In builds where it IS set, the metadata indicates (incorrectly) it will be here:
....\<SolutionDir>\bin\obj\Debug\WpfApp1\Debug\netcoreapp3.1\App.xaml
And it's not really y'alls fault, just trying to figure a solution for people who want to have a single bin and obj folder.
I have a plan to chase down the MSBuild side of this but maybe you'll have some insight since one of the collectors works and the other two do not. I only debugged the coverlet.msbuild portion.