Last active
March 21, 2019 21:43
-
-
Save GeorgDangl/13b4f4674529772f3bf0d3ced5a6677e to your computer and use it in GitHub Desktop.
Publishing an ASP.NET Core Electron App to a Single Self Contained Executable https://blog.dangl.me/archive/transform-your-aspnet-core-website-into-a-single-file-executable-desktop-app/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [PathExecutable("electronize")] readonly Tool ElectronNET; | |
| Target PublishElectronApp => _ => _ | |
| .DependsOn(Clean) | |
| .DependsOn(GenerateVersion) | |
| .Requires(() => DocuBaseUrl) | |
| .Requires(() => DocuApiKey) | |
| .Executes(async () => | |
| { | |
| // Electron Build | |
| ElectronNET(arguments: "build /dotnet-configuration Standalone /target win", workingDirectory: SourceDirectory / "Dangl.WebGAEB"); | |
| EnsureCleanDirectory(OutputDirectory); | |
| // Copy bundle to output path | |
| MoveDirectory(SourceDirectory / "Dangl.WebGAEB" / "bin" / "desktop" / "electron.net.host-win32-x64", OutputDirectory / "electron"); | |
| // Clean settings and web.config files | |
| foreach (var configFile in GlobFiles(OutputDirectory / "electron" / "resources" / "app" / "bin", "appsettings.*.json", "WebGaebSettings.*.json", "web.*.config")) | |
| { | |
| DeleteFile(configFile); | |
| } | |
| // Package electron bundle with warp | |
| var warpDownloadPath = "https://github.com/dgiagio/warp/releases/download/v0.3.0/windows-x64.warp-packer.exe"; | |
| await Nuke.Common.IO.HttpTasks.HttpDownloadFileAsync(warpDownloadPath, OutputDirectory / "warp.exe"); | |
| var warpSettings = new ToolSettings() | |
| .SetToolPath(OutputDirectory / "warp.exe") | |
| .SetWorkingDirectory(OutputDirectory) | |
| .SetArgumentConfigurator(a => a | |
| .Add("--arch windows-x64") | |
| .Add(@"--input_dir .\electron") | |
| .Add("--exec electron.net.host.exe") | |
| .Add("--output WebGAEB.Desktop.exe")); | |
| var warpProcess = ProcessTasks.StartProcess(warpSettings); | |
| warpProcess.WaitForExit(); | |
| // Run editbin on warp executable | |
| var editbinSettings = new ToolSettings() | |
| .SetToolPath(RootDirectory / "tools" / "editbin.exe") | |
| .SetWorkingDirectory(OutputDirectory) | |
| .SetArgumentConfigurator(a => a | |
| .Add("/subsystem:windows") | |
| .Add("WebGAEB.Desktop.exe")); | |
| var editbinProcess = ProcessTasks.StartProcess(editbinSettings); | |
| editbinProcess.WaitForExit(); | |
| // Build documentation | |
| DocFXBuild(x => x.SetConfigFile(RootDirectory / "docfx.json")); | |
| // Upload to DanglDocu | |
| WebDocu(s => s | |
| .SetDocuBaseUrl(DocuBaseUrl) | |
| .SetDocuApiKey(DocuApiKey) | |
| .SetSourceDirectory(OutputDirectory / "docs") | |
| .SetVersion(GitVersion.NuGetVersion) | |
| .SetAssetFilePaths(new string[] { OutputDirectory / "WebGAEB.Desktop.exe" })); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment