Skip to content
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

How to build and deploy an unpackaged app made using C# "WinUI 3 in Desktop", so that I can distribute it to others? #6620

Open
Realinspirer opened this issue Jan 18, 2022 · 25 comments
Labels
area-NugetPackage Issue with the nuget package developer experience (e.g. build error, missing files) area-Unpackaged product-winui3 WinUI 3 issues question team-Markup Issue for the Markup team

Comments

@Realinspirer
Copy link

I recently made two unpackaged WinUI 3 desktop applications (using the Blank App, Packaged (WinUI 3 in desktop) project), and made an exe file by using the Publish option that is inside the right-click menu of the main project node.
The application ran just fine on my machine. Actually, I already installed the Windows App SDK runtime and MSIX packages, as mentioned in Create a WinUI 3 app that it is required to run the app. So, it worked fine on my machine.
Then I got on another PC, and tried to run the application, but it didn't run. I then installed the Windows App SDK runtime on that machine also, and then tried to run it, but it still didn't work.

I read many docs, and I am exhausted as hell. But still I didn't find any solution that worked. I just cannot make it work.

Can you guys tell me the steps to properly deploy my app, so that I can distribute it to users. And also, please mention the runtimes/things that the user has to install to make the app work.... Please try to give fewer external links to official docs, as I have have (I forgot grammar) enough of those. I said fewer, you can still mention them, as I must have missed many things. In short, JUST GIVE ME A SOLUTION!

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Jan 18, 2022
@FinnurHrafn
Copy link

I have had similar issues as you trying to get unpacked WinUI 3 apps to run. Error messages if any are not helpful. It seems as many others have problems too. I think currently the best approach is to use the MSIX packaged apps approach. That has been trouble free for me so far in my early experiments. Yes that means signing the code with certificates but going forward that is the way to go.

@Realinspirer
Copy link
Author

Realinspirer commented Jan 19, 2022

I have had similar issues as you trying to get unpacked WinUI 3 apps to run. Error messages if any are not helpful. It seems as many others have problems too. I think currently the best approach is to use the MSIX packaged apps approach. That has been trouble free for me so far in my early experiments. Yes that means signing the code with certificates but going forward that is the way to go.

You mean that I should distribute the .msixbundle of my application, and users have to manually install the certificates, to install it?

@FinnurHrafn
Copy link

Yes, that would mean you distribute an xxx.msix file with all dependencies included. If you use a certificate from a recognized authority then there is no need for the users to manually install the certificates. Otherwise as you say they would need to install them manually. Still just for the initial install I believe.
If your users have access to a shared folder then the App Installer method seems workable to distribute and update msix apps.
Please be aware the this is something I have just read and not tried myself yet.
https://docs.microsoft.com/en-us/windows/msix/app-installer/app-installer-file-overview

@Realinspirer
Copy link
Author

Can't I just create a Console Application, named as Setup, which the user just has to click, and it will install the certificate and sideload the application too. I am not asking for the steps; I am just asking 'Can't I'.

@FinnurHrafn
Copy link

I don't know but you might want to ask on the WinUI Community Call later today. In earlier calls they have been quite busy answering live questions.
#6593

@sh0622-kim
Copy link

@Realinspirer
I had a similar experience.
Please check this part. I am distributing the program without using MSIX this way.

Case 1

If an error similar to the Windows Event Log occurs, it is considered a bug in the publish function.

Application: App1.exe
CoreCLR Version: 6.0.121.56705
.NET Version: 6.0.1
Description: The application requested process termination through Environment.FailFast.
Message: Dll was not found.
Stack:
   at System.Environment.FailFast(System.String)
   at Microsoft.Windows.ApplicationModel.DynamicDependency.BootstrapCS.AutoInitialize.AccessWindowsAppSDK()
   at <Module>..cctor()
Application: App1.exe
CoreCLR Version: 6.0.121.56705
.NET Version: 6.0.1
Description: The application requested process termination through System.Environment.FailFast(string message).
Message: Unable to find an entry point named 'MddBootstrapInitialize' in DLL 'Microsoft.WindowsAppRuntime.Bootstrap.dll'.
Stack:
   at System.Environment.FailFast(System.String)
   at Microsoft.Windows.ApplicationModel.DynamicDependency.BootstrapCS.AutoInitialize.AccessWindowsAppSDK()
   at <Module>..cctor()

Expected cause of problem
Windows App SDK publishes Microsoft.WindowsAppRuntime.Bootstrap.dll missing.
(I think this is a Windows App SDK 1.0 bug.)

Case 2

Please include DDLM check and install in your program.
You can refer to the document below.

Module Initializers : https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-9.0/module-initializers
Microsoft WindowsAppRuntime DDLM Install : https://docs.microsoft.com/en-us/windows/apps/windows-app-sdk/deploy-unpackaged-apps

@Realinspirer
Copy link
Author

@Realinspirer I had a similar experience. Please check this part. I am distributing the program without using MSIX this way.

Case 1

If an error similar to the Windows Event Log occurs, it is considered a bug in the publish function.

Application: App1.exe
CoreCLR Version: 6.0.121.56705
.NET Version: 6.0.1
Description: The application requested process termination through Environment.FailFast.
Message: Dll was not found.
Stack:
   at System.Environment.FailFast(System.String)
   at Microsoft.Windows.ApplicationModel.DynamicDependency.BootstrapCS.AutoInitialize.AccessWindowsAppSDK()
   at <Module>..cctor()
Application: App1.exe
CoreCLR Version: 6.0.121.56705
.NET Version: 6.0.1
Description: The application requested process termination through System.Environment.FailFast(string message).
Message: Unable to find an entry point named 'MddBootstrapInitialize' in DLL 'Microsoft.WindowsAppRuntime.Bootstrap.dll'.
Stack:
   at System.Environment.FailFast(System.String)
   at Microsoft.Windows.ApplicationModel.DynamicDependency.BootstrapCS.AutoInitialize.AccessWindowsAppSDK()
   at <Module>..cctor()

Expected cause of problem Windows App SDK publishes Microsoft.WindowsAppRuntime.Bootstrap.dll missing. (I think this is a Windows App SDK 1.0 bug.)

Case 2

Please include DDLM check and install in your program. You can refer to the document below.

Module Initializers : https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-9.0/module-initializers Microsoft WindowsAppRuntime DDLM Install : https://docs.microsoft.com/en-us/windows/apps/windows-app-sdk/deploy-unpackaged-apps

Will Self-contained feature come to WinUI 3? I have done many things, but still can't figure out the problem. I also checked the Event Logs; it just says that random (not same every time) dlls not found and sometime some other error. I checked if Self-contained is available or not, but didn't found much. I found out about this - <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>. But it doesn't work.

@gabbybilka gabbybilka added the product-winui3 WinUI 3 issues label Feb 8, 2022
@StephenLPeters StephenLPeters added area-NugetPackage Issue with the nuget package developer experience (e.g. build error, missing files) area-Unpackaged team-Markup Issue for the Markup team needs-triage Issue needs to be triaged by the area owners and removed needs-triage Issue needs to be triaged by the area owners labels Mar 3, 2022
@StephenLPeters
Copy link
Contributor

@MikeHillberg FYI

@Realinspirer
Copy link
Author

@MikeHillberg FYI

What?

@danielttran
Copy link

Is this the "next" generation of MS program? Project reunion? My experience has been nothing but bad about this WIN UI thing. Please make it an exe and when i double click on it, it runs everywhere.

@Realinspirer
Copy link
Author

Is this the "next" generation of MS program? Project reunion? My experience has been nothing but bad about this WIN UI thing. Please make it an exe and when i double click on it, it runs everywhere.

WinUI3 is still improving day by day. Don't worry everything will be fixed. And for the time being, you can use the MSIX packaging system, so it's not a big deal. Unpackaged apps are also there, but I think there's some deployment issue with that. And also, why to keep using the old school things, that's what I think. So, think ahead, and don't become a conservative. ☺️

@GiantappMan
Copy link

I'm trying to find a way to run a WINUI application the traditional way, just double-click the EXE file and launch it.
But I didn't find a way, I gave up on WINUI temporarily.
Hopefully, WINUI can do this like a WPF application.

@Realinspirer
Copy link
Author

Realinspirer commented Apr 16, 2022

I'm trying to find a way to run a WINUI application the traditional way, just double-click the EXE file and launch it. But I didn't find a way, I gave up on WINUI temporarily. Hopefully, WINUI can do this like a WPF application.

I think that’s how it is supposed to be, just a double-click to open exe file, except for just requiring a runtime package. But for some problems/reasons that is not working. Even after installing the runtime package it is still failing to load up the app. I don’t know what to even do, and MSIX packaging is not the way to do it. The crazy part - the app I made ran on my PC (PC that I used to make it) and even on my old PC after I installed the runtime packages. But when I distributed it to others, it was not running on their PC, so I cleaned up my old PC, reinstalled Windows, then installed the runtime packages on that computer. AND TO MY SURPRISE IT DIDN'T RUN??? Why? I have no answer. Why did it ran the other time but not this time? Maybe there’s something that is required else than just the runtime package, but the main thing is that I DIDN'T USE MY OLD PC TO MAKE THAT APP! I seriously have no idea what the freak happened! Aaah… I think it’s just an everyday programmer problem lmao.

@mlynch
Copy link

mlynch commented May 8, 2022

I'm also struggling with this. I can get an unpackaged app building and working where I can run it right from the exe, but not when it's actually installed through a setup program.

@SubashiniMahendran
Copy link

I am also facing the issue with exe of WinUI Unpackaged application. Please find below scenarios:

  • Not able to run the exe of unpackaged application in other any PC that was created in windows 10 machine.
  • Able to run the exe of unpackaged application in other PC that was created in windows 11 machine.

@mlynch
Copy link

mlynch commented Jun 28, 2022

Are you using WebView2 by chance? If not, use the Event Viewer on windows to see if there are any application errors. Unfortunately, unpackaged apps aren’t working well at the moment so I would avoid building them until some big blockers are resolved. We had to switch to WPF in the meantime

@Realinspirer
Copy link
Author

I am also facing the issue with exe of WinUI Unpackaged application. Please find below scenarios:

  • Not able to run the exe of unpackaged application in other any PC that was created in windows 10 machine.
  • Able to run the exe of unpackaged application in other PC that was created in windows 11 machine.

The unpackaged app doesn't run on any other machine than the development one, irrespective of Windows version. For me, I made my app on Windows 11, and it doesn't work on any other machine.

@Realinspirer
Copy link
Author

Are you using WebView2 by chance? If not, use the Event Viewer on windows to see if there are any application errors. Unfortunately, unpackaged apps aren’t working well at the moment so I would avoid building them until some big blockers are resolved. We had to switch to WPF in the meantime

I checked the event viewer, I don't think that helped. It said that there was some problem with random dlls. Well, it ran perfectly on the development machine.

@mlynch
Copy link

mlynch commented Jun 28, 2022

I'm assuming you all installed the required runtimes on those machines? I have no issue launching unpackaged exe's after they've been installed and assuming I'm not using any broken APIs like WebView2

@Realinspirer
Copy link
Author

I'm assuming you all installed the required runtimes on those machines? I have no issue launching unpackaged exe's after they've been installed and assuming I'm not using any broken APIs like WebView2

Yeah, you sure can assume that. Well, I am not alone on the boat. Unpackaged apps are not running on different machines for many. Also, no, it didn't use WebView2. It was a simple app.

@mlynch
Copy link

mlynch commented Jun 28, 2022

Alright, well this looks like yet another issue for the long list of unpackaged app issues

@Realinspirer
Copy link
Author

Alright, well this looks like yet another issue for the long list of unpackaged app issues

One more thing. Now that I think about it, I think that Event Viewer may have something interesting. Well, if I remember, one of the dll mentioned was 'PerfWatson' or something. But the point is that this dll is included in Visual Studio, right? Then why it's being mentioned in the unpackaged app's failure event log? Also note that, I am just trying to recall a few things from my memory, that's a bit foggy, so, I may not remember correctly. No I don't have Alzheimer's, it's just that I have tackled with WINUI 3 long ago.
I may soon check it again. But I don't know why but that dll is something I feel like I am quite sure of. But still not sure.

@bpulliam bpulliam removed the needs-triage Issue needs to be triaged by the area owners label Oct 27, 2022
@symonxdd
Copy link

It's been more than a year, and developers still can't deploy their apps to one single exe? Ridiculous...

@GuildOfCalamity
Copy link

This works for me, if using WinUI3...
[In your csproj]

<PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
    <TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
    <ApplicationManifest>app.manifest</ApplicationManifest>
    <Platforms>x86;x64</Platforms>
    <RuntimeIdentifiers>win10-x86;win10-x64</RuntimeIdentifiers>
    <UseWinUI>true</UseWinUI>
    <EnableMsixTooling>true</EnableMsixTooling>
    <!-- 
        WindowsPackageType defines whether your app is packaged (MSIX) or unpackaged (None) 
    -->
    <WindowsPackageType>None</WindowsPackageType>
    <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
</PropertyGroup>

You'll need to also make sure you've selected "Unpackaged" from the debugging dropdown...
image

If you do not see the (Unpackaged) option, you should confirm your launchSettings.json has the two profiles configured...

{
  "profiles": {
    "WinUIDemo (Package)": {
      "commandName": "MsixPackage"
    },
    "WinUIDemo (Unpackaged)": {
      "commandName": "Project",
    }
  }
}

@xiaopoyang-msft
Copy link

Self-contained is the default deployment mode by using the Publish option.

If your app is packaged with external location or unpackaged, then the Windows App SDK dependencies are copied next to the .exe in your build output. You can xcopy-deploy the resulting files, or include them in a custom installer.

But for the Framework-dependent deployment mode, check the Prerequisites beforehand. You need to use the same Major version as yourWindows App SDK for Windows Runtime.
I deployed successfully using both of the deployment modes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NugetPackage Issue with the nuget package developer experience (e.g. build error, missing files) area-Unpackaged product-winui3 WinUI 3 issues question team-Markup Issue for the Markup team
Projects
None yet
Development

No branches or pull requests