WPF SDK feedback - netfx/corefx multitargeting
See original GitHub issueI built a proof of concept for sharing code between Desktop and Core versions of WPF:
The repository is at https://github.com/gulbanana/wpf-multitarget. It works well enough to be very encouraging; here are some gotchas I ran into along the way.
-
The SDK doesn’t contain a glob for Page items, nor does it nest them using DependentUpon.
-
Building in visual studio sometimes takes a couple of tries. in particular the first clean rebuild seems to fail. This seems related to the generated xaml project.
-
When importing the props and targets, netfx must not use Microsoft.NET.Sdk.Wpf, because it already has winfx.targets coming from Microsoft.NET.Sdk. However, corefx needs the WPF targets imported after the core sdk targets. this means we can’t use
Project Sdk=
but must instead decompose the sdk into hand-written imports. -
Error messages are poor; in particular, failures to load xaml will be reported at runtime as a ArgumentNullException failing to format an error. Here’s an incomprehensible stack trace which really meant “you have failed to declare an xmlns in a resource dictionary”:
-
dotnet build
cannot be used yet, presumably due to the dependency on Microsoft.WinFX.targets. I’m sure this one is a known issue, but it’s irritating… yet useful for multi-targetting compatibility. Can we make sure that multitargeting remains possible when this is somehow fixed? 😃 -
The lack of a Properties.cs in .net core projects - for the most part a good thing - means that there’s no obvious place to put the ThemeInfo attribute required for control xaml discovery.
-
You basically have to be a WPF expert to discover most of this. Sharing code between legacy netfx and new corefx apps is going to be a major use case, so it could really use templates and polish. At the moment, if you fall slightly off the interop path then you get upsettting msbuild errors (“required targets are missing” and everything unloads itself) or upsetting runtime errors (“load failure in something xaml did somewhere”).
Issue Analytics
- State:
- Created 5 years ago
- Reactions:8
- Comments:7 (5 by maintainers)
Top GitHub Comments
I believe all of the feedback has been addressed at this point. Let me know if I’m missing something and we can reopen.
Everything’s working well in the builds I’ve tested.