'Config XamlRuntime and DefaultXamlRuntime in csproj file meaning
I try to figure out what the following csproj config means. I googled, but failed to find a result for <XamlRuntime> or $(DefaultXamlRuntime).
<ItemGroup>
<Page Update="Views\SetupTests.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
</ItemGroup>
Solution 1:[1]
The XamlRuntime and DefaultXamlRuntime properties were introduced because there are different flavors (or frameworks or runtimes - they are still discussing the right term) of XAML that require different compilers and different build tools. The reason was distinguishing WPF and the upcoming WinUI, which both use XAML. Here is the issue on GitHub with the changes for WPF:
For now, we'll keep the globbing in WPF targets, and add the appropriate Item metadata and project property, so that vs tooling can distinguish WPF from WinUI in .NET core projects.
This issue originated from another issue for adding globbing support for WinUI projects, so that the project files are not modified for each XAML file that is added, like in the old .NET Framework projects.
This issue is still open and there is also a more general proposals for both WinUI the .NET SDK.
- Proposal: Remove the need to specify XAML files in project files
- Proposal: Add generic globbing support for .xaml files
The value for DefaultXamlRuntime for WPF is defined in Microsoft.NET.Sdk.WindowsDesktop.targets:
<DefaultXamlRuntime Condition="'$(DefaultXamlRuntime)'==''">Wpf</DefaultXamlRuntime>
In the proposal for generic globbing, the default runtime for WinUI is also mentioned:
<DefaultXamlFramework Condition="'$(DefaultXamlFramework)'=='' and $(UseWpf)'!='true'">WinUI</DefaultXamlFramework>
As @Alp mentioned, there are or were issues related to copy-pasting XAML files that lead to the creation of superflous metadata in the project file and that might be what you are expieriencing.
Solution 2:[2]
I have found these question on dotnet/wpf repo on github. I also did not understand what is mean exactly but i am sharing them with you, maybe they can little help for you.
I am suspecting they are about copy/paste xaml files into your project.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Alp |
