microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.55k stars 8.31k forks source link

Guide for build and installation #489

Closed ZgblKylin closed 5 years ago

ZgblKylin commented 5 years ago

Tools needed

  1. VS2017 or higher with the following packages ("Workloads" tab in Visual Studio Installer) : 1.1 Desktop Development with C++. 1.2 Universal Windows Platform Development. 1.3 Windows 10 SDK (10.0.18362.0). 1.4 If you're running VS2019, you'll also need to install either v141 Toolset or v142 Toolset.
  2. Git command-line tool.
  3. Nuget.exe (Needed in build step 3, can be found in Terminal/dep/nuget).

Build Steps

  1. git clone this repository, not download .zip file.
  2. Run git submodule update --init --recursive in Terminal folder.
  3. Run nuget restore OpenConsole.sln (This step can be skipped, then Visual Studio should warn you that there are packages to restore - then restore).
  4. Open OpenConsole.sln with Visual Studio.
  5. Build whole solution(F7) with your platform(x86/x64) and release mode, you may need to fix some build errors: 5.1 C2220 and code page warnings: All errors and warnings are encoding error of unicode characters, a helpful workaround is to modify corresponding file encoding to UTF-8 BOM (Notepad++ is recommended). 5.2 Errors in src/tools/vtpipeterm/main.cpp: In addtion, you should also add u8 prefix before string literals with unicode characters, e.g. line 395, 398, 401 and 404.

Workaround

Try build with PR 458 or PR 549, both of them can build successfully.

Installation

Unfortunately, the generated .appx doesn't have any certificates, so it cannot be installed via double-click or powershell, the only way to install is to deploy the solution in VS.

  1. Open Windows Settings - Upgrade & Security - For Developers, switch App sources to Developer mode.
  2. Right click on CascadiaPackage project (under Solution/Terminal), select Deploy Solution to install, then you'll find Windows Terminal (Preview) in start menu.

Settings

After open the terminal, you can't see any menu buttons.

Just press Ctrl + T to open a new tab, and you'll see a drop-down button in the tab bar.

Click it and select Settings, then you can modify the configuration via opened profiles.json.

Add WSL

  1. Create a new session in profiles, with content copied from profiles/cmd.
  2. Give it a new guid.
  3. Give it a new name, such as WSL.
  4. Specify its commandline to wsl.exe.

Then you'll find WSL in the drop-down menu of tab bar.

Here're sample codes:

{
    "guid": "{09dc5eef-6840-4050-ae69-21e55e6a2e62}",
    "name": "WSL",
    "colorscheme": "Campbell",
    "historySize": 9001,
    "snapOnInput": true,
    "cursorColor": "#FFFFFF",
    "cursorShape": "bar",
    "commandline": "wsl.exe",
    "fontFace": "Consolas",
    "fontSize": 12,
    "acrylicOpacity": 0.75,
    "useAcrylic": true,
    "closeOnExit": false,
    "padding": "0, 0, 0, 0"
}
wellsluo commented 5 years ago

Add some supplements if you encountered many errors in VS2017:

iamting747 commented 5 years ago

git submodule update --init --recursive

Thanks @kbalint I had run it but had run it in the folder above where I ran git clone and I had not cd'd into the Terminal sub-directory. That error is now resolved and trying to build again. Thanks for the help! Robin

Now I am getting this error and now only 7 fail to build so it is progress:

error C3859: Failed to create virtual memory for PCH

Does anyone know how to fix this one?

hi, I have got this error too, I have gooogle it, and get some information. so I closed some app in windows, only leave vs2017 and Chrome, build it again, and everything is ok, build success.

:)

rw3iss commented 5 years ago

Fair warning: I installed Insider Build a day ago, got this all working, things were fine, nothing intense running, all the sudden the computer just gave me nonstop BSOD, and nothing worked, no system restores, couldn't boot into safemode. Only thing that worked was resetting pc and keeping files, but have to reinstall all software, grumble. Not really sure why it happened, but maybe related.

dybb8999 commented 5 years ago

Some time build project have an error :cann't find file winrt/TerminalApp.h. We need install WinRT C++ library: https://marketplace.visualstudio.com/items?itemName=CppWinRTTeam.cppwinrt101804264

robinwilson16 commented 5 years ago

@handyjellyfish I have now managed to get further and am left with just one build error. The problem was that I needed to use a different version of msbuild (noticed the nuget command references this other one) so ran these commands:

mkdir C:\Terminal
cd C:\Terminal
git init
git clone https://github.com/microsoft/Terminal.git
cd Terminal
git submodule update --init --recursive
"C:\Terminal\Terminal\dep\nuget\nuget.exe" restore OpenConsole.sln
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\bin\msbuild.exe" OpenConsole.sln

This results in a single error which is:

"C:\Terminal\Terminal\OpenConsole.sln" (default target) (1) ->
"C:\Terminal\Terminal\src\host\exe\Host.EXE.vcxproj.metaproj" (default target) (2) ->
"C:\Terminal\Terminal\src\host\exe\Host.EXE.vcxproj" (default target) (4) ->
"C:\Terminal\Terminal\src\tsf\tsf.vcxproj" (default target) (18) ->
(ClCompile target) ->
  c:\terminal\terminal\src\tsf\precomp.h(26): fatal error C1083: Cannot open include file: 'atlbase.h': No such file or
 directory [C:\Terminal\Terminal\src\tsf\tsf.vcxproj]

Is there a way to fix this last error then I think I am good to go and maybe the commands above are useful for others as took me a while to figure out.

robinwilson16 commented 5 years ago

Thanks @cybercatgurrl now I finally have it working. :) I really wish I could have built it myself but at least now I can try it.

For anyone trying this you need to first install the certificate into the Local Computer Trusted Root Certification Authorities store (by clicking it and picking where you want it to be installed) then the msixbundle should install it.

xdagee commented 5 years ago

can't see deploy after building. anyway we can run in cmd?

Do you see the Solution Explorer side menu? If not, then press Ctrl+Alt+L or go to View -> Solution Explorer. At the top of the Solution Explorer, the top most item is: Solution 'OpenConsole' (47 projects). Right click it and choose Deploy Solution from the context menu.

image

saw it, deployed but got errors. CaptureErrorDeploying

hereistheusername commented 5 years ago

I have followed the following steps:

  • I upgraded to insider build 1903.
  • Installed VS2019 Community
  • Installed Visual Studio Build Tools 2017 and 2019
  • Added:
    1. C++ (v142 & v141) Universal Windows Platform tools
    2. Windows 10 SDK (10.0.18362.0 & 10.0.17763.0)
    3. MSVC v142 & v141 – VS 2019 C++ x64/x86 build tools
    4. C++ ATL for v141 & v142 build tools (x86 & x64)
    5. C++/WinRT
  • Installed WinRT package
  • Run:
    1. git clone https://github.com/microsoft/Terminal.git
    2. git submodule update --init --recursive
    3. nuget restore OpenConsole.sln
  • Opened Project/Solution from VSCode
  • Right-click "Solution 'OpenConsole'" and "Build Solution" => no errors (succeeded)
  • Right-click "Terminal -> WindowsTerminal" and Debug -> New Instance

And after all this: exception_base h

Exception thrown at 0x00007FFB6AF4A839 in WindowsTerminal.exe: Microsoft C++ exception: winrt::hresult_error at memory location 0x00000086DA31E808.

I have the same problem as you.

I have followed the following steps:

  • I upgraded to insider build 1903.
  • Installed VS2019 Community
  • Installed Visual Studio Build Tools 2017 and 2019
  • Added:
    1. C++ (v142 & v141) Universal Windows Platform tools
    2. Windows 10 SDK (10.0.18362.0 & 10.0.17763.0)
    3. MSVC v142 & v141 – VS 2019 C++ x64/x86 build tools
    4. C++ ATL for v141 & v142 build tools (x86 & x64)
    5. C++/WinRT
  • Installed WinRT package
  • Run:
    1. git clone https://github.com/microsoft/Terminal.git
    2. git submodule update --init --recursive
    3. nuget restore OpenConsole.sln
  • Opened Project/Solution from VSCode
  • Right-click "Solution 'OpenConsole'" and "Build Solution" => no errors (succeeded)
  • Right-click "Terminal -> WindowsTerminal" and Debug -> New Instance

And after all this: exception_base h

Exception thrown at 0x00007FFB6AF4A839 in WindowsTerminal.exe: Microsoft C++ exception: winrt::hresult_error at memory location 0x00000086DA31E808.

Edit: I think the team had a reason there's not a binary, it's not ready yet. I think I'll wait till mid June. Have some good sprints!

@Berrysoft still not working, got some errors this time (unfortunately I deleted all repos and tools related with Terminal (40+ gb together with the components installed)

How did you succeed at first time? I even got tons of errors.

newbalancem5 commented 5 years ago

I have followed the following steps:

* I upgraded to insider build 1903.

* Installed VS2019 Community

* Installed Visual Studio Build Tools 2017 and 2019

* Added:
    1. C++ (v142 & v141) Universal Windows Platform tools
    2. Windows 10 SDK (10.0.18362.0 & 10.0.17763.0)
    3. MSVC v142 & v141 – VS 2019 C++ x64/x86 build tools
    4. C++ ATL for v141 & v142 build tools (x86 & x64)
    5. C++/WinRT
* Installed WinRT package

* Run:
    1. git clone https://github.com/microsoft/Terminal.git
    2. git submodule update --init --recursive
    3. nuget restore OpenConsole.sln
* Opened Project/Solution from VSCode

* Right-click "Solution 'OpenConsole'" and "Build Solution" => no errors (succeeded)

* Right-click "Terminal -> WindowsTerminal" and Debug -> New Instance

And after all this: exception_base h

Exception thrown at 0x00007FFB6AF4A839 in WindowsTerminal.exe: Microsoft C++ exception: winrt::hresult_error at memory location 0x00000086DA31E808.

Edit: I think the team had a reason there's not a binary, it's not ready yet. I think I'll wait till mid June. Have some good sprints!

@Berrysoft still not working, got some errors this time (unfortunately I deleted all repos and tools related with Terminal (40+ gb together with the components installed)

this work, ty

zadjii-msft commented 5 years ago

@cybercatgurrl please don't use github threads as a place to redistribute third-party binaries. There's a reason binaries aren't available for download quite yet.

@hereistheusername Try deploying "CascadiaPackage" to run the new terminal. If you're having any build issues arround "Terminal.TerminalSettings", try manually building the TerminalSettings project first. There seems to be some sort of issue with the build order, where it doesn't always build it first.

luit0r commented 5 years ago

I'd rather sit and wait for and update rather than download 16 gig worth vstudio

hereistheusername commented 5 years ago

When I used Git bash,I was told bash:nuget:command not found How to solve it?

Terminal/dep/nuget. You can find it there, and add the directory to path, or copy it to root directory of the project.

hereistheusername commented 5 years ago

@cybercatgurrl please don't use github threads as a place to redistribute third-party binaries. There's a reason binaries aren't available for download quite yet.

@hereistheusername Try deploying "CascadiaPackage" to run the new terminal. If you're having any build issues arround "Terminal.TerminalSettings", try manually building the TerminalSettings project first. There seems to be some sort of issue with the build order, where it doesn't always build it first.

Ok. I'll try orderly.

sodle commented 5 years ago

Where does one even download Visual Studio 2017? All I can find on Microsoft's site is 2019.

newbalancem5 commented 5 years ago

Where does one even download Visual Studio 2017? All I can find on Microsoft's site is 2019.

https://visualstudio.microsoft.com/vs/older-downloads/

vsavic commented 5 years ago

I've followed the steps, built the solution successfully, but I'm getting this error when I try to deploy: 17>LINK : fatal error C1007: unrecognized flag '-Yu' in 'p2' Anyone else getting the same thing?

Me too.

creatorsrk commented 5 years ago

It absolutely needs to be put into the Readme that you can NOT use Visual Studio 2019, especially since Microsoft is known for making legacy software harder to access (including Visual Studio 2017, which after uninstalling it I still don't know how to re-download).

Using VS2019's update tool doesn't work either.

VS2019 works. We need to retarget the Solution File and Update the Framework to use 4.6 Then Build the Solution. It worked for me

robinwilson16 commented 5 years ago

@zadjii-msft I'm really liking the new console and the fact it is open source and we can try out out early in dev and was able to set it up with PowerShell 6, WSL and am SSH'd into my Ubuntu box as I speak. However whilst I am a dev who uses VS 2017/2019 every day I couldn't get this to build whatever I tried so was only able to try it because of the binary that was kindly posted. Could more complete instructions be provided of a single working approach to save everyone running into the same issues if you will not allow binaries to be shared to avoid some of the frustrations?

handyjellyfish commented 5 years ago

@zadjii-msft I'm really liking the new console and the fact it is open source and we can try out out early in dev and was able to set it up with PowerShell 6, WSL and am SSH'd into my Ubuntu box as I speak. However whilst I am a dev who uses VS 2017/2019 every day I couldn't get this to build whatever I tried so was only able to try it because of the binary that was kindly posted. Could more complete instructions be provided of a single working approach to save everyone running into the same issues if you will not allow binaries to be shared to avoid some of the frustrations?

@robinwilson16 - after my fun with VS2019 Build Tools I got someone to run it in VS2017 and it was a breeze. These were the steps we took:

As an aside I'd guess that VS2019 would work exactly the same, just need to change the platform toolset to VS2019, but haven't tried it.

I don't think it's quite ready for command line building - you can get it done, but with the self signing of the installer etc etc it's just a bit convoluted.

chunliu commented 5 years ago

See #565 for build with VS2019 and from command line.

vstoms commented 5 years ago

Quick blogpost about how to build Windows Terminal in Azure Dev-Ops: https://blog.stomsvik.com/posts/2019/terminal-azure-devops/

knilecrack commented 5 years ago

gotta love github

snooopcatt commented 5 years ago

@robinwilson16

c:\terminal\terminal\src\tsf\precomp.h(26): fatal error C1083: Cannot open include file: 'atlbase.h': No such file or directory [C:\Terminal\Terminal\src\tsf\tsf.vcxproj]

you need to install C++ ATL. you can do it via same tool you use to install visual studio

Remi-Tuy commented 5 years ago

hello. can I download the binary file of you build ? I don`t want to build it . no environment . 😆

@clearcodecn did you manage to get a binary from anybody ?

Does anybody have a link to the binary ? No environment to build on my machines :/

l1005268416 commented 5 years ago

Thank you.

davidfries commented 5 years ago

@Remi-Tuy

I got a link from a reddit thread, just installed on an updated Win10 insider VM and it works! term

Here's a link (edited: please don’t share binaries) for a build. This is not my build, and you're responsible for any damages that result from installing. From this thread

vsavic commented 5 years ago

Any idea why this error:

venabled commented 5 years ago

Any idea why this error:

@vsavic Just had the exact error as you. Retargeted the whole solution to v142, and then manually right clicked TerminalApp in the Solution Explorer, and then Add->Reference to TerminalSettings

jintianzhouyine commented 5 years ago

i have added WSL setting in profile.json,but i can't open WLS window. image

l1005268416 commented 5 years ago

非常感谢。Windows Terminal我已利用vs2017编译部署成功。

1005268416@qq.com

From: blurredpixel Date: 2019-05-09 23:47 To: microsoft/Terminal CC: l1005268416; Comment Subject: Re: [microsoft/Terminal] Guide for build and installation (#489) @Remi-Tuy I got a link from a reddit thread, just installed on an updated Win10 insider VM and it works! Here's a link for a build. This is not my build, and you're responsible for any damages that result from installing. From this thread ― You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

l1005268416 commented 5 years ago

你如果已经编译成功的话,可以按照以下步骤来安装Windows Terminal: 1.选中CascadiaPackage项目,点击鼠标右键,选择部署,等待其部署成功。

2.部署成功后,开始菜单中就会显示Windows Terminal,启动它就可以了。

3.效果图:ctrl+T 可以打开新标签。

1005268416@qq.com

From: FrancescoPacifico Date: 2019-05-10 03:31 To: microsoft/Terminal CC: l1005268416; Comment Subject: Re: [microsoft/Terminal] Guide for build and installation (#489) Hi, I've succesfully built the solution:

But when I try to deploy it I get this error:

Can you help me getting rid of this? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

klize commented 5 years ago

I followed the guide and tried to deploy the project, but failed with so many MIDL2003 errors.

My Env: Win 10, SDK 10.0.18362.0 VS2017 Any prerequisites installed I think. I cannot found any issues like mine.

I also tried 10.0.17763.0 in VS2017 but it tells I have to deploy with the 10.0.18362.0. Could anyone can tell me the solution ? I really hope to try this new one.

fredrikaverpil commented 5 years ago

Even if you need Windows 10 "1903" to run (and possibly other tools installed locally), why not publish the Cascadia package as a build artifact as a last step in the already existing Azure Pipelines CI?

klize commented 5 years ago

Even if you need Windows 10 "1903" to run (and possibly other tools installed locally), why not publish the Cascadia package as a build artifact as a last step in the already existing Azure Pipelines CI?

Thanks, that may work. I realize that i cannot get os build 1903 , as i am not the insider. just preparing the sdk doesn't solve my problem. (vs only reads the system version 1809 )

chithangduong commented 5 years ago

Quick blogpost about how to build Windows Terminal in Azure Dev-Ops: https://blog.stomsvik.com/posts/2019/terminal-azure-devops/

Thanks for the tutorial. This seems to be the best way to build since you don't need to install VS2019 or any libs.

sryze commented 5 years ago

Can anybody clarify why the 10.0.18362.0 SDK is needed? will this terminal not run on Windows 10 versions before 1903?

I was excited about the new terminal and tried to build the app in VS but then I learned that you actually need a yet unreleased version of Windows in order to do it...

zadjii-msft commented 5 years ago

@sryze Because we depend on features that only shipped in the newest version of Windows, namely certain XAML Islands functionality.

Biswa96 commented 5 years ago

Though this is not an serious issue VS/msbuild shows double slashes in project paths in build output.

krokofant commented 5 years ago

If you've managed to deploy once via Visual Studio you can use the devenv.exe to do it smoothly via command-line next time:

devenv .\OpenConsole.sln /Deploy

I'm using posh-vsdev to enter the VS dev environment but you might also just reference that executable directly.

paddymcd-MSFT commented 5 years ago

Worked through a few issues but I've got OpenConsole.sln building from the command-line with VS2019 installed. Thanks to @olgaark

You need the following optional Workloads / Components installed:

On the Workloads tab

For x86 / x64 builds (some of the SDKs may not be necessary - I haven't checked)

On the Individual components tab

Then running msbuild.exe OpenConsole.sln using msbuild.exe from the VS2019 installation should work. This does not require any dev console or use of vcvarsall.bat.

upupming commented 5 years ago

@ZgblKylin You are my hero, thanks! For me, I forgot to change from arm64 to x64 build type. You saved me, thanks again.

Another question, 4.1 & 4.2 are true problems I faced, but why didn't Microsoft fix them? Okay, I see the PRs you mentioned, hope they will be merged or resolved someday!

krystian-mw commented 5 years ago

========== Build: 0 succeeded, 45 failed, 2 up-to-date, 0 skipped ==========

You forgot to change the architecture. Right next the "Debug" dropdown (next to the redo button) you should change the architecture to your own system. I initially thought to myself there's no way I'll get it working :P

roshan-raj commented 5 years ago

image I am currently running Windows 1903, Build 18334.19h1 , but i have set the target version to 18362, as i had downloaded 10.0; Build 18362. SO now should i be upgrading my windows or is there a workaround ?

CaptainMorgans commented 5 years ago

How do I do this in the "Terminal" folder which doesn't exist as a folder in the console?

Run git submodule update --init --recursive in Terminal folder

I can however find the CascadiaPackage folder.

I managed to run this command in the CascadiaPackage folder and yet I still get errors "wil/Common.h: No such file or directory"

christian-korneck commented 5 years ago

This is how it worked for me:

reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock /v AllowDevelopmentWithoutDevLicense /d 0 /t REG_DWORD /f
git clone https://github.com/microsoft/Terminal.git
cd Terminal
git submodule update --init --recursive
nuget restore OpenConsole.sln

Result: There's a new start menu entry Windows Terminal (Preview)

CaptainMorgans commented 5 years ago

@christian-korneck Thank you for the steps. All worked up until the Deploy step.

========== Build: 21 succeeded, 4 failed, 0 up-to-date, 0 skipped ========== ========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========

Errors below

Severity Code Description Project File Line Suppression State Error C1007 unrecognized flag '-Yu' in 'p2' TerminalControl C:\Terminal\src\cascadia\TerminalControl\LINK 1

Error LNK1257 code generation failed TerminalControl C:\Terminal\src\cascadia\TerminalControl\LINK 1

Error MIDL2011 [msg]unresolved type declaration [context]: Microsoft.Terminal.Settings.KeyChord [ Parameter 'chord' of Procedure 'SetKeyBinding' ( RuntimeClass 'TerminalApp.AppKeyBindings' ) ] TerminalApp C:\Terminal\src\cascadia\TerminalApp\AppKeyBindings.idl 62

Error MIDL2011 [msg]unresolved type declaration [context]: Microsoft.Terminal.Settings.IKeyBindings [ RuntimeClass 'TerminalApp.AppKeyBindings' ] TerminalApp C:\Terminal\src\cascadia\TerminalApp\AppKeyBindings.idl 59

Error C1083 Cannot open include file: 'winrt/TerminalApp.h': No such file or directory WindowsTerminal C:\Terminal\src\cascadia\WindowsTerminal\AppHost.h 7

Error C1083 Cannot open include file: 'winrt/TerminalApp.h': No such file or directory WindowsTerminal C:\Terminal\src\cascadia\WindowsTerminal\AppHost.h 7

Error C1083 Cannot open include file: 'winrt/TerminalApp.h': No such file or directory WindowsTerminal C:\Terminal\src\cascadia\WindowsTerminal\IslandWindow.h 7

Error C1083 Cannot open include file: 'winrt/TerminalApp.h': No such file or directory WindowsTerminal C:\Terminal\src\cascadia\WindowsTerminal\IslandWindow.h 7

Error Specified EntryPointExe 'WindowsTerminal.exe' was not found in the project outputs. CascadiaPackage C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\DesktopBridge\Microsoft.DesktopBridge.targets 413

image

mehulmpt commented 5 years ago

screen

Here is what I get on building. I've tried everything mentioned above, but couldn't find solution to it. Can anybody check it out and see what should be done?

dantenull commented 5 years ago

“wil/Common.h”: No such file or directory how is this error resolved???

kjhajeh commented 5 years ago

Run git submodule update --init --recursive in Terminal folder Run nuget restore OpenConsole.sln (This step can be skipped, then Visual Studio should warn you that there are packages to restore - then restore)

I found that these steps didn't work for me when I downloaded the ZIP file. It's better to just clone it using git clone, then use those steps. Hopefully this helps someone who might have run into the same problem that I did :D

kjhajeh commented 5 years ago

“wil/Common.h”: No such file or directory how is this error resolved???

You should try cloning the repository again via git clone (not downloading the ZIP file). Then you run these two commands within the Terminal directory:

git submodule update --init --recursive

Then, change directory into dep/nuget

Then, run: > nuget restore OpenConsole.sln

TIP: you may also try >nuget restore (path to openconsole sln) if nuget isn't in your PATH (which it probably isn't). Just remember to be in the nuget directory.

Hope this helps!