-
Notifications
You must be signed in to change notification settings - Fork 701
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
Unable to consume custom and/or templated control using nuget packages in WinUi 3 C#/.Net #7830
Comments
Hi @bpulliam! |
@bpulliam I am also waiting on this. |
@bpulliam could you please elaborate on when this bug is planned to be fixed? |
How is this a feature proposal lol... |
@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 microsoft/WindowsAppSDK#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. |
Hi @Overrided, I've created a discussion thread giving the answer about how to solve the In short, when generating the nuget package, you could either:
|
Describe the bug
I'm trying to package
xaml templated control
into nuget package and then consume it inC#/WinUI 3
packaged app.In
UWP
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 Crash when referencing resource dictionary with styles in WinUI 3 Preview 2 #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 stillbuild/pack but would not be referenced by consumer app.
The text was updated successfully, but these errors were encountered: