-
Notifications
You must be signed in to change notification settings - Fork 0
AOT Packaged
This is a reprint from the \Documents\Notes.txt
CREATES AN AOT PACKAGED EXECUTABLE for .Net8/WinUI/WinAppSDK1.7/c#/Win-x64 using VS2022
Note: We are using the free JetBrains dotPeek app to decompile .exe's back to c# source.
DEBUGGING AS NON-AOT
-
You can debug like usual as it builds a non-AOT AOTSample.exe in E:\Code\VS\AOTSamples\AOTSample\bin\x64\Debug\net8.0-windows10.0.22621.0\win-x64. It installs a debug package viewable on your start menu. To find out where it is installed, go to Powershell and type
Get-AppxPackage | Select-Object Name, PackageFullName, InstallLocation
It is likely at the bottom of the list. The location is the same as noted above. This will change when you do a Package and Publish operation.
Double-click it and it will not not run. But it can be decompiled back to source. Copy the AOTSample.exe and AOTSample.dll To it's own folder and check it in dotpeek. If you don't copy it to it's own folder, dotPeek crashes.
PUBLISHING AS AOT
- Running the project/Publish wizard creates AOT binaries, but it is not the published msix package we need for installation.
PACKAGE AND PUBLISH AS AOT Before we get started, uninstall the debug package from your start menu (right-click on it, uninstall).
-
Run the project/Package and Publish/Create App Packages wizard.
- Select Sideloading with no auto update (although you could do this, it doesn't affect AOT).
- Assign a certificate.
- Auto-increment the version, generate app bundle=Never (since it's just x64).
- select x64 Release from the list, don't include public symbol files. It will default to what you have set on the v2022 main toolbar.
We now have an installer
- Hit Create and it will bring up the location of the published files. It may send you to a non-existent debug subfolder if you didn't set 'release' on the main toolbar. Go there.
- In this test, it created the installation package at \bin\x64\Release\net8.0-windows10.0.22621.0\win-x64\AppPackages\AOTSample_1.0.3.0_x64_Test. It appends a _Test to the foldername since it is sideload and not for the Microsoft store.
- Uninstall the debug version first from the start menu, then double-click on the ex. AOTSample_1.0.4.0_x64.msix to start the installer and it will install the package and you will see it in the Start menu.
Ok, it is installed
- To find out where it installed on your system, go to powershell and type
Get-AppxPackage | Select-Object Name, PackageFullName, InstallLocation
In this example it installed to: C:\Program Files\WindowsApps\AOTSample_1.0.4.0_x64__et3p35edsb9cp
- Go there in File Explorer and you'll see the AOTSample.exe. Open it in dotPeek and you will see it is unmanaged, so no IL for decompiling. The AOT executable can still be decompiled with difficulty, but at least they don't get your full c# source code.
To go back to debugging, you'll need to uninstall this release version first.
POWERSHELL PACKAGE AND PUBLISH I'm not sure how to do this. It would likely be a multi-line script.
What about these \Generated Files ? These are auto-generated by the ide based on the AOT project settings.