-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
.NET MAUI Windows target publishing/archiving #4329
Comments
Adding this here, we had to figure this out as well, and this is the gist of how I setup the GitHub Actions pipeline : https://gist.github.com/Sweekriti91/75d019ea832e800aee860e54fe7da7c5 |
Hi, I have tried your workaround, but it keeps failing with this error I have tried to fiddle with MauiApp1.csproj, but no luck so far
|
Note that my command starts with msbuild not dotnet build. That's key here 😊 |
Now it is working, thank you |
Thank you! This really helped. I was able to install and run it but only on my dev machine, when I moved it to my non-dev machine it didn't work. Which makes me think that some of the .net SDKs were not added to the application. Has anyone been able to run it in another machine without .net SDKs installed? Update, even tried to install VS22 preview and it still didn't work on the non dev machine |
@igalfsg that's interesting, I will try that. If you go into the Event Viewer, do you see any entries there that might give you a clue on why it's not working? I think the idea of an msix file is that it installs the SDK needed, right? Edit: just tried it myself on a Windows 10 machine that is not a dev machine. MSIX runs without a problem and installs the prerequisites needed. |
Interesting, that it works for you, I will try a different machine? Forgot to mention the event viewer on my first comment. That was the weirdest part, event viewer said the install was fine and everything was successful. |
@jfversluis Thank you so much for looking into it. I am trying to setup a release MSIX( or APPX,) and while they installed successfully, they wouldn't run (like nothing happens if you go to start menu → start the app). I am wondering if I setup my certificate wrong, or I just didn't configure app bundle config wrong. I am just not sure. I am going to give @Sweekriti91's gist Github Action a try and see if it will build Blazor Maui app → MSIX correctly (@Sweekriti91 Thanks for this gist, it is handy for someone who lacks experiences with github action like me!) |
@WetMonitor would you be able to look in the Event Viewer if there is an entry there with more info? I think I've seen an issue with the custom font that is registered with the default .NET MAUI template, but when I tried to reproduce it later I couldn't. Do you still have the font in there? Could it be that? |
@jfversluis If I take rename the bundled APPX file to ZIP and look into its content, I still see the fonts: As for event viewer... Let me try (keep in mind, it was installed with APPX, not MSIX- I'm in the process of trying to build one atm)
Edit: I'm going to try and see if I can get MSIX version working now. |
Ah so this is a .NET MAUI Blazor app? That one doesn't seem to work for some reason :( |
@jfversluis Correct. It's indeed a .NET MAUI Blazor app. I don't know if that makes any difference? If you want to RDP into my WinDev2112Eval machine to take a closer look or to troubleshoot this, feel free to holla me (I can be found DootNetEvaluation maui discord channel.) |
Yeah that does make a difference for some reason. Not sure why though. So if you have anything you discover in that regard I would be curious to know! |
Mine is also Blazor, that might be the problem for me too. Adding @danroth27 so Blazor team has visibility into this issue. |
@mkArtakMSFT Looks like we need someone to look into this .NET MAUI Blazor deployment issue. |
Having similar issues with a Maui/Blazor app. I have figured out this much in terms of building the msix by msbuild at the command line: When I install the app on a non-dev machine, nothing appears and I get the following in Windows Event Viewer: Replaced an existing DispatcherProvider with one from the service provider. Error: Application Error |
@jfversluis I tried your solution and im able to generate the app package. But in cake file using the below code im able to generate the app package but it failed after generation with the error as below. Cake: Error: |
@PaulAnderson02 here is the solution to the error you've been seeing: microsoft/microsoft-ui-xaml#6746 Seems like something is missing on your build host :) |
@danroth27 @jfversluis @Eilon any thoughts on my comment? |
The fastlink error is because I think we are missing some msvc dependency or runtime. Try installing the uwp workload. It is this one I believe there is a fix somewhere near. |
I've spoken about it briefly with @danroth27 who mentioned the impact might be limited because WebView2 is apparently installed by a lot of other products so chances are pretty big it should already be there. However, for the best experience we want to make sure of course. I think he was going to look into it. Maybe this has something to do with it as well? #5086 |
I can only speak as someone who rolled out a WPF App using BlazorWebView and had about 10 users report needing to install the runtime (I had not realized it wasn't packaged so I didn't mention it in the repo) so I think there may be an assumption that people "already have it", which is an assumption I had. Regardless, it would be ideal to ship the Nuget package with all the dependencies it has rather than pushing the responsibility to end users. |
Hi @isaacrlevin. We are currently advocating using the evergreen model for WebView2 with .NET MAUI. MAUI developers using WebView2 will need to ensure that WebView2 is installed on the machine as part of their app setup using either the online or offline techniques described in the WebView2 docs. We are discussing with the WebView2 team how to make appropriate samples & docs available for how to do this with .NET MAUI apps. |
Thanks @danroth27! I went through the docs and even some of the samples the WebView2 team has for Installer apps for instance, and my ideal scenario is that there would be both a standalone doc as well as a repo with how to "ship" apps with BlazorWebView (that would obviously be accurate for WinForms, WPF and MAUI). Publishing packages to the Microsoft Store is already challenging currently for .NET Core 3.1 and up apps (MSBUILD, different deployment types, etc.) and including WebView2 adds another wrinkle for devs. Just my .02, you can ignore it ;) |
Hello @danroth27, as the creator of the #5086 pull request and the issue #3861, working with everygreen versions has some limitations. Like in my scenario I want to ship the Edge Canary version to use preview features like WebGPU, which are not available in the everygreen version but only in Canary previews and will not be for the next year or two? And when I deploy a BlazorWebView application and it works for only 90% of my users as reported out of the box it is problematic. But more importaintly for BlazorWebView would be to be able to define your own environment, since sometimes you need to set special flags like --custom-devtools-frontend to disable or modify the devtools. Or --enable-unsafe-webgpu for WebGPU. Thank you for your time! |
@MichaelPeter Thanks for this feedback! We do anticipate that we will need to support fixed version distribution of the browser control. It was scoped out for the initial release of Blazor Hybrid support due to time and resource constraints. Your feedback does help us understand how quickly we need to address this scenario. Please be sure to 👍 the related issues and comment with your scenarios and requirements. |
How early @jfversluis ? I still was able to reproduce in #3542 from a template that I got on the 30th of Jan (it referenced |
I think templates around that time would still have it. You can run |
I tried the third approach and get this error:
|
We have official docs now on how to publish to an MSIX at least. We have a couple of loose ends (and issues to track them) open to finish up some other things but I think we can close this one for now. |
How I create a a certificate with thumbprint in app store? |
@danies8 you'll have to follow the instructions to create a certificate and make sure the thumbprints match. If you want to roll out to the store you actually don't even need to sign your msix as it will be signed by the Microsoft Store. |
Can you please provide an answer? |
This is a closed issue so I recommend filing a new issue with details of how to reproduce, etc. |
TL;DR
Description
I have been trying to see if publishing a Windows app through .NET MAUI works at the moment. There are a few different variations, most don't work, but I have been able to produce a working msix file.
Ideally I would think
dotnet publish
would be supported. However if we look at the csproj file we see that we needMSBuildRuntimeType == full
. So the only way to achieve anything right now is by using msbuild.Disclaimer: my knowledge on Windows apps isn't all that great, so there might be things in here that don't even make sense in this context. I found some options through
GoogleBing and decided to try them out, here are the results.Questions
Background
1. Basic command (doesn't work)
msbuild_basic.binlog.zip
The most obvious command then is
msbuild /restore /t:Publish /p:TargetFramework=net6.0-windows10.0.19041 /p:configuration=release
. This completes successfully, however the resulting published app won't work. You can double-click the main exe, but nothing comes up. Also, the build artifacts in the release folder show the same behavior (why that is important we will see later).In the Windows Event Viewer, I see this entry after I tried to start the app:
Sure enough the mentioned DLL
Microsoft.ui.xaml.dll
is not present amongst the huge amount of files both in the build artifacts and the publish folder.2. Adding
-p:PublishSingleFile=true
(doesn't work)msbuild_singlefile.binlog.zip
Command:
msbuild /restore /t:Publish /p:TargetFramework=net6.0-windows10.0.19041 /p:configuration=release -p:PublishSingleFile=true
With this command the publish folder only contains a couple of files, which I guess makes sense. The build artifacts still is a huge list of files. However, running still results in nothing happening. The Event Viewer shows a somewhat similar entry, but lacks the
Microsoft.ui.xaml.dll
filename this time.3. Adding
-p:WindowsAppSDKSelfContained=true
(somewhat works)msbuild_windowsappsdk.binlog.zip
Command:
msbuild /restore /t:Publish /p:TargetFramework=net6.0-windows10.0.19041 /p:configuration=release -p:WindowsAppSDKSelfContained=true /p:Platform=x64
Then I somewhere found the
WindowsAppSDKSelfContained
option and decided to try that. Initially it fails, because it seems this option does not supportAnyCPU
:The platform 'AnyCPU' is not supported for SelfContained mode.
I added the
x64
platform through the Visual Studio Configuration Manager Then adding the/p:Platform=x64
option made it complete successfully.Here is where things get interesting. There are now a big number of files in the publish folder, but running the exe still does not work. There is an event logged in the Event Viewer identical to option 1.
However! If I now navigate up a folder and just look at the build artifacts and run the exe there, it works! The difference seems to be that there are a number of files in the build artifacts that don't end up in the publish folder. Running a compare between the two folders, these are the files that seem to be different:
When this option is combined with the
-p:PublishSingleFile=true
we get a singe file in the publish folder which won't run, however if we copy it back to the build artifacts folder that also runs. So it would seem that the DLLs it's missing also don't end up in the single file.Another weird thing with this option is; the app runs, but I can't move the window! You can resize the window, but you can't move it for whatever reason.
4. Adding
/p:GenerateAppxPackageOnBuild=true
(WORKS!)Command:
msbuild /restore /t:Publish /p:TargetFramework=net6.0-windows10.0.19041 /p:configuration=release /p:GenerateAppxPackageOnBuild=true /p:AppxPackageSigningEnabled=true /p:PackageCertificateThumbprint="{your thumbprint}" /p:PackageCe rtificatePassword="{your password}"
(also tried /t:Build)This generates some files in the
AppPackages
folder that wasn't there before which contains anmsix
file. That won't let me install because of a certificate error it seems.I went to find how I should sign my msix file and found that I had to create a self-signed certificate and then I could add a couple of extra parameters to also add the sign the MSIX and then trust that cert manually... AND IT WORKS!
We now have an msix file that can install/update/run the app 🎉
Other
/p:SelfContained=true
option which doesn't seem to have any influence. I also tried different variations of all the options above, but none of them seemed to work.Package.appxmanifest
file because double-clicking it would give me an error (see below). For a regular UWP app, the editor opens and works fine.Related Resources
Also See
The text was updated successfully, but these errors were encountered: