Skip to content

Dev17 breaks ability to compile some WPF projects #18062

@jaredpar

Description

@jaredpar

Dev17 breaks WPF project builds when project files were using the Microsoft.Net.Sdk and manually listing out the XAML files in the project. For example:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net472</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Reference Include="PresentationCore" />
    <Reference Include="PresentationFramework" />
    <!-- few more omitted for brevity -->
  </ItemGroup>

  <ItemGroup>
    <ApplicationDefinition Include="App.xaml">
      <Generator>MSBuild:Compile</Generator>
      <SubType>Designer</SubType>
    </ApplicationDefinition>
    <Page Include="MainWindow.xaml">
      <Generator>MSBuild:Compile</Generator>
      <SubType>Designer</SubType>
    </Page>
  </ItemGroup>

</Project>

This approach worked in both Dev15 and Dev16 but breaks in Dev17. I ran into this when migrating VsVim to work on top of Dev17. The break here is subtle because under the hood it's just not passing the .g.cs files to the compiler anymore. That means you end up with strange errors like in ability to access controls by name that you designed in a XAML file. If you have purely design XAML then likely you end up with compiling code but strange runtime behavior.

The repro is a bit involved here so I created a GitHub repo that contains the full code that will reproduce the issue. The README.md has instructions.

https://github.com/jaredpar/Dev17WpfUpgradeIssue

Metadata

Metadata

Assignees

No one assigned

    Labels

    untriagedRequest triage from a team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions