AvaloniaVS
AvaloniaVS copied to clipboard
Visual Studio messes up project file when UserControl/Window added from template
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>
Adding <EnableDefaultNoneItems>False</EnableDefaultNoneItems>
solves this issue for me
Templates use "axaml" format now, so it's not an issue anymore.