Open Overrided opened 1 year ago
Hi @bpulliam!
Any news on this?
I mean it's really needed and basic feature - being able to distribute and reuse custom components using nuget packages
.
@bpulliam I am also waiting on this.
@bpulliam could you please elaborate on when this bug is planned to be fixed?
This is show-stopper for me since I can't reuse any templated control
without copying code, which is ridiculous to have in goddamn 2023!!
How is this a feature proposal lol... This is clearly a blocking issue.
@JesseCol I'm glad this is going at least somewhere. Is there any estimate on this feature request?)
@Overrided have you tried using the Windows Community Toolkit controls within your app? We have been packaging and building templated controls on top of WinUI 3 since the beginning without issue. This seems like a doc/sample/configuration issue that's been overlooked somewhere that's led you to this badstate?
(Also seems related to #6452 and https://github.com/microsoft/WindowsAppSDK/issues/3546)
@michael-hawker nope, didn't use Community toolkit, I've tried custom control in both my and reference solutions from Microsoft and fired this bug. Had no chance to try it with latest .net etc, will check.
Describe the bug
I'm trying to package
xaml templated control
into nuget package and then consume it inC#/WinUI 3
packaged app. InUWP
this was working, but inWinUI 3
it seems to be broken.In my attempt I was following documentation: CsWinRT Authoring Windows App Sdk Applications, Xaml Templated Controls C# WinUI 3
and samples: CsWinRT AuthoringDemo, WindowsAppSDK CustomControls
Using WindowsAppSDK CustomControls sample as a codebase, I've tried to pack
WinUIComponentCs
project asnuget package
and then use it inCsApp
instead of directly referencing projects as it is shown in sample.Now, if
consumer
app project directly referencescustom control
project, everything works as expected, all custom controls are available.But once using same
custom control
vianuget package
,consumer
app crashes withMicrosoft.UI.Xaml.Markup.XamlParseException: 'XAML parsing failed.'
error.Exception details:
If exception is allowed to propagate further, it shows a bit more details:
For more context and additional testing scenarios please see fork of WindowsAppSDK CustomControls, and follow
Steps to reproduce the bug
.Steps to reproduce the bug
Perform
dry run
to establish baseline in terms ofexpected behavior
.1.1. Clone fork of WindowsAppSDK CustomControls
1.2. Checkout
NugetCustomControlBug
branch.1.3. Navigate to
...\WindowsAppSDK-Samples\Samples\CustomControls
subfolder.1.4. Open
CsWinRTAuthoringWinUI.sln
usingVisual Studio
.1.5.
Build
solution (NOTE: I'm only interested inC#/.Net
part ofWinUI 3
so far, so noC++
-related observations where made).1.6. Set
CsApp
asStartup Project
(InVisual Studio
-> right click onCsApp
project -> selectSet as Startup Project
).1.7. Launch
CsApp
application in 'packaged' configuration. (InVisual Studio
-> pressF5
).1.8. Verify all 3 available scenarios -
Custom Control
,User Control
andTemplated Custom Control
- are not crashing whenCsApp
(consumer app) directly referencesWinUIComponentCs
(custom control library). Please see verification inScreenshots
section.Modify
CsApp
app to consumecustom controls
usingNuGet package
and observe crash.2.1. Pack
WinUIComponentCs
project into nuget package (InVisual Studio
-> right click onWinUIComponentCs
project -> selectPack
or usingdotnet cli
).2.2. Copy
WinUIComponentCs.1.0.0.nupkg
from previos step to...\WindowsAppSDK-Samples\Samples\localpackages
folder.2.3. In
CsApp
remove reference toWinUIComponentCs
(InVisual Studio
-> ExpandCsApp
projectDependencies
-> expandProjects
-> selectWinUIComponentCs
-> pressdelete
).2.4. In
CsApp
installWinUIComponentCs.1.0.0.nupkg
nuget package from step2.1.
(InVisual Studio
-> right click onCsApp
project -> selectManage Nuget Packages
-> setPackage source
tolocalpackages
-> selectBrowse
tab -> selectWinUIComponentCs
package in package list -> clickInstall
).2.5. Launch
CsApp
application in 'packaged' configuration. (InVisual Studio
-> pressF5
).2.6. Select
User Control
orTemplated Custom Control
scenario and observe crash.Expected behavior
Expected behavior is same as established in a
dry run
part ofSteps to reproduce the bug
-Custom Control
,User Control
andTemplated Custom Control
scenarios are working and not crashingCsApp
.Screenshots
Dry run
scenarios verification:Consuming
WinUIComponentCs
as Nuget Package:User Control
failureTemplated Custom Control
failureNuGet package version
WinUI 3 - Windows App SDK 1.1.5
Windows app type
Device form factor
Desktop
Windows version
Windows 11 (22H2): Build 22621, Windows 11 (21H2): Build 22000, Windows 10 (21H2): Build 19044, Windows 10 (21H1): Build 19043, Windows 10 (20H2): Build 19042
Additional context
Additional steps to reproduce different errors I was able to reproduce while trying to manually reference
xaml
markup of custom controls:Case 1
CsApp
app.Cannot locate resource from 'ms-appx://WinUIComponentCs/Themes/Generic.xaml'. [Line: 20 Position: 37]
like in this #3371 issue.Case 2
CsApp
app.Failed to assign to property 'Microsoft.UI.Xaml.ResourceDictionary.Source' because the type 'Windows.Foundation.String' cannot be assigned to the type 'Windows.Foundation.Uri'. [Line: 17 Position: 37]
like in this issue #6674.Case 3
Change
WinUIComponentCs
's name to something with '.' (dot character
) in it - likeWinUIComponentCs.Core
. Project will still build/pack but would not be referenced by consumer app.