You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How can one deploy Windows Terminal from command line? #926
I've built successful from command line using the following command. msbuild /p:Configuration=Release /p:Platform=x64 /p:PlatformToolset=v142 /p:TargetPlatformVersion=10.0.18362.0 /p:PreferredToolArchitecture=x64 OpenConsole.sln
I'm trying to find a possible solution for deploying from the command line. Is adding /p:DeployOnBuild=true enough? What other things need be done if necessary? Any guidance on what Deploy does, e.g. copying files to where, writing some environmental variables?
No this is not enough as the deploy is actually deploying a UWP app, which isn't from MSBuild. Using things like the WinAppDeployCmd SDK tool might be an option here, but I think also a powershell script is probably the easiest...I haven't looked to see if anyone started one or not.
I've got a work item assigned to me for this. It's possible to deploy it as a "dev build" with Add-AppXPackage and using the AppManifest.xml as a path target with the -Register switch, but this install lacks taskbar and start menu icons (it's just a black square.) Additionally, I've had intermittent problems with launching the app like this - occasionally it opens with a blank white window and hangs.
The long-winded way to install it is to create a self-signed certificate (New-SelfSignedCertificate), add it as a local trusted root, and run the generated Add-AppDevPackage.ps1 that sits in the Cascadia output folder. Additionally, you have to run a Release build (use bzc rel) as the Debug build won't generate an AppXBundle by default as it's a lengthy process. It should be obvious that we cannot ship a self-signed .pfx in the project as this would be dangerous - just ask Lenovo (Superfish)
When you deploy the Cascadia project with Visual Studio, it handles the certificate part for you.
Oisin Grehan (@oising) I can't locate the AppManifest.xml file in the project. Does one need to create it manually? If yes what exactly should be in it?
AppManifest.xml is auto-generated by visual studio when building the package. It's possible that msbuild would build it too, but I'm not 100% positive on that. I know it's generated from package.appxmanifest, as well as some other metadata the project knows about it's dependencies.
So I think self-signed is fine for dev builds but for official released builds, a proper certificate i needed. To put in simple terms, it's easier to grab the appx bundle from Artifacts from latest commit and install it (either double-click or PS script) than to have to grab Visual Studio and build the solution. Right now attempting to grab an appx from Artifacts and installing it will fail unless you have Developer-Mode on as there is no cert or it's considered untrusted by Windows. Unfortunately Developer Mode breaks Win32-OpenSSH, which I and a bunch of other people use (It can be more convenient than opening a WSL session just to remote into another host).
I am trying to build and run Windows Terminal from the command-line. I did manage to build it using the PowerShell module, but I am unable to launch either WindowsTerminal.exe or wt.exe. There's a mention that one cannot launch it outside of Visual Studio, but why is that? Is code signing mandatory in order to launch Windows Terminal? I have successfully copied the files from an existing MSIX installation into a temporary directory and launched it from there, so what's different from trying to launch one that was just built from source?
So, the most annoying part of the modern app platform is that there are multiple different parties responsible for "laying out" an application. Visual Studio has one version of "layout", and the commandline build tools have another. In fact, the CLI doesn't actually lay the app out, it just makes a zip file (well, msix file) with source/destination paths. It never puts the application all into one folder where it can just be run.
VS lays the app out correctly on disk and registers that layout with the OS as a "loose package". It's not code signing, just... a bunch of sqlite gunk in a database somewhere plus a folder in the right layout with a resources.pri file in it. Annoying, but necessary.
If you want to figure out how to possibly maybe get it running from the CLI, check out the VSCode project configuration, where we have an obnoxiously long deployment command.
How does the Windows Terminal team automate their builds, then? I'm pretty sure it's not someone pushing a button in Visual Studio from their work laptop, and then deploying it for millions of people to use :) Or at least I hope that's not the case!
Hah! So, our release builds are produced by that "list of loose files -> msix package" step I mentioned above for the CLI build. It produces a single unsigned msix which you can (1) extract to a temporary folder and run or (2) codesign and install directly.
This will build the .msix (CascadiaPackage -> %OPENCON%\src\cascadia\CascadiaPackage\AppPackages\CascadiaPackage_0.0.1.0_x64_Debug_Test\CascadiaPackage_0.0.1.0_x64_Debug.msix)
This takes 25s, on my desktop, even if there's nothing to build. So this takes a while.
This still needs to get deployed! This will only build the msix.
I think these will deploy the package:
# If you haven't already:Import-Module tools\OpenConsole.psm1;
Set-MsBuildDevEnvironment;
# The Set-MsBuildDevEnvironment call is needed for finding the path to# makeappx. It also takes a little longer to run. If you're sticking in powershell, best to do that.Set-Location-Path src\cascadia\CascadiaPackage\AppPackages\CascadiaPackage_0.0.1.0_x64_Debug_Test;
if ((Get-AppxPackage-Name 'WindowsTerminalDev*') -ne$null) {
Remove-AppxPackage'WindowsTerminalDev_0.0.1.0_x64__8wekyb3d8bbwe'
};
New-Item ..\loose -Type Directory -Force;
makeappx unpack /v /o /p .\CascadiaPackage_0.0.1.0_x64_Debug.msix /d ..\Loose\;
Add-AppxPackage-Path ..\loose\AppxManifest.xml -Register -ForceUpdateFromAnyVersion -ForceApplicationShutdown
Or the cmd.exe version:
@rem razzle.cmd doesn't set:@rem set WindowsSdkDir=C:\Program Files (x86)\Windows Kits\10\@rem vsdevcmd.bat does a lot of logic to find that.@rem@rem I'm gonna hardcode it below:powershell -Command Set-Location -Path %OPENCON%\src\cascadia\CascadiaPackage\AppPackages\CascadiaPackage_0.0.1.0_x64_Debug_Test;if ((Get-AppxPackage -Name 'WindowsTerminalDev*') -ne $null) { Remove-AppxPackage 'WindowsTerminalDev_0.0.1.0_x64__8wekyb3d8bbwe'};New-Item ..\loose -Type Directory -Force;C:\'Program Files (x86)'\'Windows Kits'\10\bin\10.0.19041.0\x64\makeappx unpack /v /o /p .\CascadiaPackage_0.0.1.0_x64_Debug.msix /d ..\Loose\;Add-AppxPackage -Path ..\loose\AppxManifest.xml -Register -ForceUpdateFromAnyVersion -ForceApplicationShutdown
(yes, the cmd version is just calling powershell to do the powershell version. Too lazy to convert the rest by hand, I'm already copying from .vscode\tasks.json)
Now, INTERESTINGLY, building the package from VS generates the loose layout to begin with, and then registers the loose manifest, skipping the msix stop. That still takes 7s to do on my desktop (even with nothing to do), but it's a lot faster than the commandline inner loop here. I wonder if there's some config flag that can be passed to the wapproj build to get it to make the loose layout rather than the msix...
Note to self: After the changes to unpackaged, portable, etc in 1.18, there might be better ways of doing this from the commandline in the near future.
Refer to #15133 - that was one of the tip PRs for calling makepri manually. We may be able to find a way to modify that to just rebuild the package resources without needing to do the whole commandline deploy.
Activity
timheuer commentedon May 22, 2019
No this is not enough as the deploy is actually deploying a UWP app, which isn't from MSBuild. Using things like the WinAppDeployCmd SDK tool might be an option here, but I think also a powershell script is probably the easiest...I haven't looked to see if anyone started one or not.
timheuer commentedon May 22, 2019
https://docs.microsoft.com/en-us/powershell/module/appx/add-appxpackage?view=win10-ps#examples
oising commentedon May 23, 2019
I've got a work item assigned to me for this. It's possible to deploy it as a "dev build" with
Add-AppXPackageand using the AppManifest.xml as a path target with the-Registerswitch, but this install lacks taskbar and start menu icons (it's just a black square.) Additionally, I've had intermittent problems with launching the app like this - occasionally it opens with a blank white window and hangs.The long-winded way to install it is to create a self-signed certificate (
New-SelfSignedCertificate), add it as a local trusted root, and run the generatedAdd-AppDevPackage.ps1that sits in the Cascadia output folder. Additionally, you have to run a Release build (usebzc rel) as the Debug build won't generate an AppXBundle by default as it's a lengthy process. It should be obvious that we cannot ship a self-signed .pfx in the project as this would be dangerous - just ask Lenovo (Superfish)When you deploy the Cascadia project with Visual Studio, it handles the certificate part for you.
Tembocs commentedon May 27, 2019
Oisin Grehan (@oising) I can't locate the AppManifest.xml file in the project. Does one need to create it manually? If yes what exactly should be in it?
zadjii-msft commentedon May 28, 2019
AppManifest.xml is auto-generated by visual studio when building the package. It's possible that msbuild would build it too, but I'm not 100% positive on that. I know it's generated from
package.appxmanifest, as well as some other metadata the project knows about it's dependencies.[-]DeployOnBuild from command line[/-][+]How can one deploy Windows Terminal from command line?[/+]WSLUser commentedon Mar 3, 2020
So I think self-signed is fine for dev builds but for official released builds, a proper certificate i needed. To put in simple terms, it's easier to grab the appx bundle from Artifacts from latest commit and install it (either double-click or PS script) than to have to grab Visual Studio and build the solution. Right now attempting to grab an appx from Artifacts and installing it will fail unless you have Developer-Mode on as there is no cert or it's considered untrusted by Windows. Unfortunately Developer Mode breaks Win32-OpenSSH, which I and a bunch of other people use (It can be more convenient than opening a WSL session just to remote into another host).
4 remaining items
awakecoding commentedon Oct 12, 2021
I am trying to build and run Windows Terminal from the command-line. I did manage to build it using the PowerShell module, but I am unable to launch either WindowsTerminal.exe or wt.exe. There's a mention that one cannot launch it outside of Visual Studio, but why is that? Is code signing mandatory in order to launch Windows Terminal? I have successfully copied the files from an existing MSIX installation into a temporary directory and launched it from there, so what's different from trying to launch one that was just built from source?
DHowett commentedon Oct 12, 2021
So,
the most annoyingpart of the modern app platform is that there are multiple different parties responsible for "laying out" an application. Visual Studio has one version of "layout", and the commandline build tools have another. In fact, the CLI doesn't actually lay the app out, it just makes a zip file (well, msix file) with source/destination paths. It never puts the application all into one folder where it can just be run.VS lays the app out correctly on disk and registers that layout with the OS as a "loose package". It's not code signing, just... a bunch of sqlite gunk in a database somewhere plus a folder in the right layout with a
resources.prifile in it. Annoying, but necessary.If you want to figure out how to possibly maybe get it running from the CLI, check out the VSCode project configuration, where we have an obnoxiously long deployment command.
awakecoding commentedon Oct 12, 2021
How does the Windows Terminal team automate their builds, then? I'm pretty sure it's not someone pushing a button in Visual Studio from their work laptop, and then deploying it for millions of people to use :) Or at least I hope that's not the case!
DHowett commentedon Oct 12, 2021
Hah! So, our release builds are produced by that "list of loose files -> msix package" step I mentioned above for the CLI build. It produces a single unsigned msix which you can (1) extract to a temporary folder and run or (2) codesign and install directly.
zadjii-msft commentedon Nov 17, 2021
This will build the .msix (
CascadiaPackage -> %OPENCON%\src\cascadia\CascadiaPackage\AppPackages\CascadiaPackage_0.0.1.0_x64_Debug_Test\CascadiaPackage_0.0.1.0_x64_Debug.msix)I think these will deploy the package:
Or the cmd.exe version:
(yes, the cmd version is just calling powershell to do the powershell version. Too lazy to convert the rest by hand, I'm already copying from
.vscode\tasks.json)Now, INTERESTINGLY, building the package from VS generates the loose layout to begin with, and then registers the loose manifest, skipping the msix stop. That still takes 7s to do on my desktop (even with nothing to do), but it's a lot faster than the commandline inner loop here. I wonder if there's some config flag that can be passed to the wapproj build to get it to make the loose layout rather than the msix...
Add notes on building package from commandline
Add notes on building package from commandline (#11811)
zadjii-msft commentedon Apr 24, 2023
Note to self: After the changes to unpackaged, portable, etc in 1.18, there might be better ways of doing this from the commandline in the near future.
Refer to #15133 - that was one of the tip PRs for calling
makeprimanually. We may be able to find a way to modify that to just rebuild the package resources without needing to do the whole commandline deploy.Now, if only we could get the FastUpToDate check