Skip to content

Setting BaseIntermediateOutputPath or IntermediateOutputPath MSBuild properties in WPF projects causes instrumentation to fail. #976

Closed
@hymccord

Description

@hymccord

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.

  1. New solution
  2. New WPF (netcore) project
  3. New Test project (added coverlet.msbuild too)
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    tracking-external-issueThe issue is caused by external problem - nothing we can do to fix it directly

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions