黑科技抢先尝 | Windows全新终端初体验(附代码Build全过程)

本文详细介绍如何从源代码编译并体验Windows Terminal,包括升级Windows 10至1903版本、从GitHub克隆代码、安装VS2019及.NET core 3.0 SDK、配置编译环境、解决编译错误、以及在编译后的终端中使用Linux命令。

640?wx_fmt=gif


640?


微软在几天前的build大会上展示了Windows Terminal的威力,由于官宣要在6月中旬才上Microsoft store,还有一个多月要等呢。好在代码已公布在 github, 于是决定自己 build 后体验一番。遇到不少坑,大概整理一下流程,分享给大家。如果大家如果发现问题,欢迎指正。


视频如下:



640?

将Window 10 升级到1903版本

试过用Windows 10 更新助手(Windows 10 update assistant)来升级Windows 10, 发现只能升级到1809版本。而编译 github 上的 Microsoft terminal 代码必须使用Window 10的1903版本.


好在前不久听说了工具网站MSDN, 我告诉你(http://msdn.itellyou.cn/)上可以下载到该版本的镜像。

640?wx_fmt=png

关于版本选择,到底选Consumer版还是Business版呢?经大佬Edi Wang指点,得悉如下信息:

  • 如果你的 Windows 是 家庭版,请选择Consumer

  • 如果你的 Windows 是 专业版或企业版,请选择Business


至于ed2k://资源的下载,你使用百度云盘的离线下载也好,使用迅雷也行。


640?

安装好git, 从github上clone代码

首先需要安装好git for Windowshttps://gitforwindows.org/),然后使用 git 去 clone 一份代码。


Microsoft Terminal 的 github仓库是:

https://github.com/microsoft/Terminal

对应的 clone地址是:

https://github.com/microsoft/Terminal.git


打开命令行,使用cd命令,切换到自己平时存vs项目的路径(比如我切换到D:\Coding)。

接着只需要在Git Bash中输入如下命令即可:

git clone https://github.com/microsoft/Terminal.git

640?wx_fmt=png

等 clone 完成,就可以进行下一步了。

确保 clone 仓库完成后,还可以使用以下命令克隆子模块:

git submodule update --init --recursive



640?

安装 VS 2019 和  .NET core 3.0 SDK

先安装 vs 2019 professional 或 enterprise版本,github上的文档提到了要编译 window terminal 必须勾选上:

  • Desktop Development with C++

  • Universal Windows Platform Development

  • Windows SDK version 10.0.18362.0


再安装好.net core 3.0 SDK,比较简单,就不再详述。

在vs的设置里,勾选.NET core下的"Use preview SDK"(使用.NET Core SDK预览版),重启 VS。

640?wx_fmt=png


在 vs 2019 中打开Windows terminal项目(对应文件夹Terminal)下的OpenConsole.sln, 如果不勾选"使用.NET Core SDK预览版"直接编译,很可能会报下面的 Error:

640?wx_fmt=png


640?

重定解决方案目标

在上一步中,用vs2019打开OpenConsole.sln时,系统会提示你将项目重新定位到 v142。 对于“Windows SDK版本”,请选择“10.0.18362.0”。 将“Platform Toolset”设置为“Upgrade to v142”。

640?wx_fmt=png

然后往下拖,按下图设置:

640?wx_fmt=png

设置完后,单击最下面的OK。


当然,如果误点了"取消",也能通过右键单击整个Solution -> Retarget solution来设置:

640?wx_fmt=png


640?

设置好编译平台和启动的项目

在你尝试再次build之前,请确保你已经选择好与你的计算机匹配的编译平台(Solution Platform)。

不知道你一开始打开SolutionOpenConsole.sln时编译平台和启动项目是什么样的,我的是这样的:

640?wx_fmt=png

要正确地 build,这里需要设置如下:

640?wx_fmt=png

否则会出现很多错误。


640?

编译成功后出现一个新的Powershell

解决完编译时的各种状况之后,Ctrl + F5运行项目。

唉,和之前的Powershell有何不一样呢?按Ctrl + T之后会多了个菜单,同一个窗口中可以有多个Tab,而其他功能暂时没进来,等正式版。此外,还多了句话(见高亮部分)~

尝试新的跨平台 PowerShell https://aka.ms/pscore6


任务栏中相应的图标为:

640?wx_fmt=png

Ctrl + T之后, 右上角会出现一个以+开头的菜单

640?wx_fmt=png

但你选择cmd的时候,视频中的酷炫效果就有出来的迹象了:

640?wx_fmt=png

接下来,介绍一下如何在上面这个新的cmd中使用Linux命令,以我最熟悉的Ubuntu为例来介绍吧。


640?

安装Ubuntu

在Microsoft store里搜索到Ubuntu,然后购买,安装。这实际上就是WSL (Windows Subsystem for Linux)。

640?wx_fmt=png

当然,你想体验其他版本的Linux,也是可以的,比如Arch Linux

640?wx_fmt=png


640?

在编译出来的命令行中使用Linux命令

安装完WSL版的 Linux 后,还需要开启WSL的权限:

以"管理员权限"另开一个PowerShell窗口,

640?wx_fmt=png

然后输入如下命令:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

640?wx_fmt=png

等这里的命令完成,就可以在build出来的 Terminal 中执行 Linux 命令了。


先在cmd中输入ubuntu, 需要花一点点时间启动Ubuntu, 设置好用户名和密码。

然后就可以愉快地玩Ubuntu了,下面我随便输入了几个命令 ps, touch, ls等,如下图所示。

640?wx_fmt=png

如有什么疑问或建议,欢迎及时留言交流。


如果自己不想配置和build,可以下载build好的体验一把:

传送门

https://pan.baidu.com/s/1Xrh-0KbsBmh-zJYsdtYqnA 口令: y233


备份地址:

https://github.com/yanglr/WindowsDevTools/tree/master/awosomeTerminal


其他玩法:

Build and install Windows Terminal from Azure DevOps ? Keep IT tidy

https://blog.stomsvik.com/posts/2019/terminal-azure-devops/


参考:

Microsoft Terminal - README.md

https://github.com/microsoft/Terminal/blob/master/README.md


Windows 子系统适用于 Linux (WSL) 上 Windows 10 上安装 | Microsoft Docs

https://docs.microsoft.com/zh-cn/windows/wsl/install-win10


Donovan Brown | Building the new Windows Terminal with Visual Studio 2019

http://www.donovanbrown.com/post/Building-the-new-Windows-Terminal-with-Visual-Studio-2019



640?wx_fmt=gif



原文地址:

https://www.cnblogs.com/enjoy233/p/awesome_windows_terminal_build_and_trial.html 

640?wx_fmt=jpeg

smiley_66.png点击"在看"的人,

2019都会变得特别好看?

v7.0.0-preview.4 - 09/19/2019 Engine Updates and Fixes Add support to ActionPreference.Break to break into debugger when Debug, Error, Information, Progress, Verbose or Warning messages are generated (#8205) (Thanks @KirkMunro!) Enable starting control panel add-ins within PowerShell Core without specifying .CPL extension. (#9828) Performance Make ForEach-Object faster for its commonly used scenarios (#10454) and fix ForEach-Object -Parallel performance problem with many runspaces (#10455) Experimental Features Update PSDesiredStateConfiguration module version to 2.0.3 and bring new tests; enable compilation to MOF on non-Windows and use of Invoke-DSCResource without LCM (#10516) Add APIs for breakpoint management in runspaces and enable attach to process without BreakAll for PowerShell Editor Services (#10338) (Thanks @KirkMunro!) Support ternary operator in PowerShell language (#10367) General Cmdlet Updates and Fixes Add PowerShell Core group policy definitions (#10468) Update console host to support XTPUSHSGR/XTPOPSGR VT control sequences that are used in composability scenarios. (#10208) Add WorkingDirectory parameter to Start-Job (#10324) (Thanks @davinci26!) Remove the event handler that was causing breakpoint changes to be erroneously replicated to the host runspace debugger (#10503) (Thanks @KirkMunro!) Replace api-ms-win-core-job-12-1-0.dll with Kernell32.dll in Microsoft.PowerShell.Commands.NativeMethods P/Invoke API(#10417) (Thanks @iSazonov!) Fix wrong output for New-Service in variable assignment and -OutVariable (#10444) (Thanks @kvprasoon!) Fix global tool issues around exit code, command line parameters and path with spaces (#10461) Fix recursion into OneDrive - change FindFirstFileEx() to use SafeFindHandle type (#10405) Skip auto-loading PSReadLine on Windows if the NVDA screen reader is active (#10385) Increase built-with-PowerShell module versions to 7.0.0.0 (#10356) Add throwing an error in Add-Type if a type with the same name already exists (#9609) (Thanks @iSazonov!)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值