AvaloniaVS icon indicating copy to clipboard operation
AvaloniaVS copied to clipboard

Visual Studio messes up project file when UserControl/Window added from template

Open grokys opened this issue 4 years ago • 1 comments

If one uses the VS extension to add a new UserControl or Window to an existing project, VS adds the following to the .csproj breaking the build by removing the XAML file we added:

  <ItemGroup>
    <AvaloniaResource Remove="UserControl1.xaml" />
  </ItemGroup>
  <ItemGroup>
    <None Remove="UserControl1.xaml" />
  </ItemGroup>

We can add this to the project file which improves things somewhat:

  <ItemGroup>
    <AvailableItemName Include="AvaloniaResource" />
  </ItemGroup>

With this, VS doesn't break the build but it does add the following (useless) entries to the .csproj:

  <ItemGroup>
    <None Remove="UserControl1.xaml" />
  </ItemGroup>
  <ItemGroup>
    <AvaloniaResource Update="UserControl1.xaml">
      <Generator>MSBuild:Compile</Generator>
    </AvaloniaResource>
  </ItemGroup>

grokys avatar Jun 04 '20 16:06 grokys

Adding <EnableDefaultNoneItems>False</EnableDefaultNoneItems> solves this issue for me

Gillibald avatar Jun 17 '20 05:06 Gillibald

Templates use "axaml" format now, so it's not an issue anymore.

maxkatz6 avatar Jun 09 '23 02:06 maxkatz6