-
Notifications
You must be signed in to change notification settings - Fork 329
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
Near-impossible to create a nuget package with WinUI 3 controls and resources #3546
Comments
Still digging through this without a resolution. I did find that once you got multiple XAML files in your project, they are no longer embedded in the .pri file. Only when you have a single Generic.xaml do you get it embedded. |
Follow-up to work around issue microsoft/WindowsAppSDK#3546
I am also looking for a resolution for this. See this issue also. |
* v200.1 * WPF Popupviewer updates (#491) * Switch to use PopupElements for popup viewer control * Address namespace changes * Update WindowsAppSDK version to match MAUI requirements (#500) * Update deprecated property * Add properties to allow compiling for .NET Framework * Fix typo * Avoid navigation string resources in toolkit package * Updates relevant to popupviewer enhancements (cherry picked from commit 273a7d7) * Update README.md Co-authored-by: Morten Nielsen <1378165+dotMorten@users.noreply.github.com> * Update docs/popup-viewer.md Co-authored-by: Morten Nielsen <1378165+dotMorten@users.noreply.github.com> * Fix min-version support in MAUI * Maui: Ensure fonts are packaged and deployed * Add support for basic HTML in popups (#504) * Work around asset deployment issues caused by WinAppSDK See microsoft/WindowsAppSDK#3546 for details * Also include assets in lib folder for library layout Follow-up to work around issue microsoft/WindowsAppSDK#3546 * Set background on toolbar --------- Co-authored-by: Morten Nielsen <mort5161@esri.com> Co-authored-by: Matvei Stefarov <mstefarov@esri.com> Co-authored-by: Preeti Maske <pmaske@esri.com>
Same problem here... |
Nuget packages created with As for the incorrect source asset paths... those are the result of an MRT target extracting from all referenced @robertzhou-wpn At a minimum I believe that the MRT Core target |
Any movement on getting this issue fixed? |
Interested in a solution for this as well. |
…ous maintenance-intensive workarounds
I have the same problem. However, in WinUI, it is done like this: Note that there is no "assembly=WpfControlLibrary" in the WinUI version. I wanted to switch to WinUI, but it still looks very immature compared to WPF. |
Here my test app in GitHub |
@AlanKharebov this seems unrelated to this issue. Also I’m not sure why you see a much simplified syntax which UWP also have had for years as signs it is immature but that’s again off topic. |
@dotMorten have you found a workaround for this issue? I doubt we will get a solution before at least a year or two... |
@abdes only via manual fixing nuget package in a post-packaging step. It sucks |
Yeah that kinda sucks. I ended up doing my coding in a mono-repo fashion so I can just reference projects. Cannot share anything via NuGet, which really sucks. By the way, another workaround is to code the UI in C#, not XAML. So I took a look at https://github.com/VincentH-Net/CSharpForMarkup but they don't support Community Toolkit controls, which kinda sucks again cause we have some good stuff in the CTK and re-coding it in C# Markup is too much effort for me. I just don't get how Microsoft envisioned WinUI without Nuget, and yeah, I get that they want to stay faithful to the fluent UI, but what's wrong with sharing views built on WinUI? |
First, I can confirm this is a big issue with WinUI. Second, there is another option. It's not great, but it appears to work: remove all the content resources from your package. My package only used about a dozen images. All of my XAML uses the "ms-appx:" syntax to identify resources, so it's easy enough to change them around to point to a local collection of resources (instead of packaged resources). If you accept that limitation, the large library of custom controls that my applications use seems to have packaged up nicely into a NuGet package. At least, with this option, I can package the common controls and XAML helpers. |
I've been going down a rabbit hole looking for something else, but I didn't think we did anything special here for the Windows Community Toolkit and have seen/tried using it in both types of app projects. @dotMorten maybe you can help me understand what the gap is here between what the Toolkit does and this issue? Or do the Toolkit components also have this issue and I just haven't realized...? We haven't heard of anyone having issues using them with WinUI 3 like this. |
@michael-hawker it's bit a while since I had to hack around this issue, but if I recall, content files aren't packaged correctly in a WinAppSDK project, compared to how UWP would package it when generating an app layout. It's put in the wrong folders and generating the nuget manifest wrong. |
Hmm, maybe we don't have many content files then in the Toolkit? I would have imagined we have something somewhere within it... it's a large project. |
@michael-hawker here's a more recent package I did, where I redirect the content file to a different folder: In UWP that was never needed - the files that the library relies on should go in the librarylayout folder and would "just work" |
Describe the bug
When creating a C# class library and using the
Pack
target, the generated nuget package is incorrectly packing content files in a way where WAP packaged apps fail to build, and single-app projects fail to find resources.Steps to reproduce the bug
MyControlLibrary
project (simple custom control with an icon and custom font included with project)ProjectRef_Test (Package)
and verify the custom control works when using a project reference to the class library. You should see this:NugetRef_TestApp
. Notice the build errors:Instead build and run
App_NugetReference_SingleApp
which doesn't use a separate packaging project. This project builds, but will crash on launch with a very unhelpful error message:We can work around the bug in Step 6, by modifying
MyControlLibrary.csproj
and adding:This however, doesn't fix the problem. We are now instead met with the following build error:
At this point I have not been able to successfully create a nuget package with WinUI controls that has content files and works with both single-project and wap projects.
However even without the workaround in Step 8, if you open the generated nuget package, you'll see both a
content
andcontentFiles
folder, and the assets are in there, however are in the wrong folder, and should be pushed further down to include the package name, or the paths likems-appx:///MyControlLibrary/Assets/...
will not be correct since it is missing the package name. Again this can sort of be work around with this:but again that doesn't really help that much, other than getting the content files deployed in the right location, but single-project app still crashes on launch.
Expected behavior
Generated nuget packages works and deploys files in the right folder.
Screenshots
No response
NuGet package version
Windows App SDK 1.2.5: 1.2.230313.1
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 22H2 (22621, 2022 Update)
IDE
Visual Studio 2022
Additional context
Note: I'm using a slight "hack" to get the sample apps use a locally built nuget-reference. Sometimes this causes restore errors, which can usually be handled by removing the obj folders in the app projects and rebuilding them, but sometimes it just wants a quick restart of VS to get it to snap out of it.
Additionally I had no luck using
<PRIResource />
instead of<Content />
either (that even breaks the project reference version).The text was updated successfully, but these errors were encountered: