-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Add generic globbing support for .xaml files #12520
Comments
@dsplaisted after our meeting earlier this week, I've updated the proposal to match what we discussed. This comment was largely deleted and the proposal was grouped in with the original comment in this issue |
One benefit of using the |
I like that idea. That would enable Avalonia to opt in easily and remove a lot of our tooling troubles. |
Can confuse users as to what is the difference between "DefaultXamlFramework" and "TargetFramework"? We used to reserve the word "Framework" for .Net. Maybe we should use instead XamlPlatform or maybe better XamlRuntimePlatform? |
Overall I like and am supportive of this. However, the details may be tricky to get right. For example, the globs are currently (and should probably continue to be) defined in .props files instead of .targets files. This allows them to be modified in the body of the project file (for example updating them to add metadata, or removing them from one item and adding to another one). For the example of updating the XamlFramework metadata to work, the default Page globs would need to happen beforehand, ie in the .props files. <ItemGroup>
<Page Update="WinUIUserControl.xaml" XamlFramework="WinUI" />
</ItemGroup> Even though they are in props files, because of the multiple phases of MSBuild evaluation, you can have items in the .props files that are conditioned on properties set in the body of the project or in .targets files. See here for some discussion of this: https://github.com/dotnet/designs/blob/master/accepted/2020/workloads/workload-resolvers.md#workload-props-files Another tricky thing will be the mechanics of changing the targets in dotnet/sdk and the WindowsDesktop targets which are in dotnet/wpf in sync. I generally prefer proposal A to proposal B. Would it be reasonable to not set the I like |
@chabiss that's a fair point. I'm a fan of either
@dsplaisted makes sense 👍
Can you share an example so I can better understand what you mean? I'm not quite sure I understand the benefit of doing it that way.
One benefit of a new item group is that it would be simpler to coordinate changes. The changes in dotnet/sdk can happen and we can update dotnet/wpf at our own pace w/o worrying about conflicting changes. If we went with Proposal A, I'd imagine that the WPF build will break once it tries to consume the .NET SDK that has this default globbing, and then we'll fix WPF and wait for a coherent build. |
Now that other XAML based UI frameworks are moving to .NET5, there needs to be a generic way for the globbing mechanism that keeps the .csproj clean that all the frameworks can use. Since the frameworks themselves don't share the same compiler toolchain, and the frameworks aren't generally compatible (integration between WinUI and WPF is in its infancy), what's added here shouldn't dictate how those projects build. It should be simple and generic, and something that WinUI, WPF, MAUI, Avalonia, and Uno can all build off of.
Proposal A: .NET SDK adds items to
Page
groupIn this proposal, the .NET sdk globs xaml files into the existing
Page
item group. It doesn't know anything about theApplicationDefinition
, and nor should it, because that logic differs between Xaml frameworks. For example, WinUI always uses App.xaml as the file name, even for VB projects. The .NET SDK uses the value of theDefaultXamlFramework
and places that on eachPage
item in theXamlFramework
metadata. TheXamlFramework
metadata is read by the necessary toolchains to understand which Xaml framework the file belongs to.(new) Microsoft.NET.Sdk.Xaml.targets:
Microsoft.NET.Sdk.WindowsDesktop.targets:
Microsoft.WinUI.NET.Markup.Compiler.targets:
Proposal B: .NET SDK has new
Xaml
item group.This proposal is very similar to A, but instead of the .NET Sdk placing items in the
Page
ItemGroup, it uses theXaml
item group instead. The WindowsDesktop SDK and WinUI would grab the xaml items out of this group, and place them in thePage
andApplicationDefinition
group as they need. The way that theDefaultXamlFramework
property works is identical as described in Proposal A.(new) Microsoft.NET.Sdk.Xaml.targets:
Microsoft.NET.Sdk.WindowsDesktop.targets:
Microsoft.WinUI.NET.Markup.Compiler.targets:
Forward thinking
What happens when we want to merge WinUI and WPF into the same project? If we look at the user scenario for this, this is the scenario of a WPF app using Xaml Islands. If I'm using Visual Studio in my WPF project, and add a WinUI item, then VS should make the following change to the .csproj:
This will ensure the existing tooling properly recognizes the page as being a WinUI page, rather than a WPF page.
I don't have a strong preference for which one, I prefer the .NET sdk having a new item group, but I'm not sure if VS would understand that if our VSIX adds .xaml files to the
Page
item group./cc @ryalanms @dsplaisted @jkoritzinsky @davkean
Related Issues:
dotnet/wpf#3245
microsoft/microsoft-ui-xaml#2498
The text was updated successfully, but these errors were encountered: