Blog/public/windows-sde/index.html
2025-01-24 15:14:06 +08:00

219 lines
13 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
<meta name="robots" content="noodp"/>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/background_dark.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich'blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/windows-sde/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich'blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/windows-sde/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="icon" type="image/png" href=&#x2F;dich.webp />
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li class="active"><a href="https://blog.dich.bid">blog</a></li>
<li><a href="https://blog.dich.bid/tags">tags</a></li>
<li><a href="https://blog.dich.bid/archive">archive</a></li>
<li><a href="https://blog.dich.bid/about">about me</a></li>
<li><a href="https://blog.dich.bid/links">links</a></li>
<li><a href="https://blog.dich.bid/search">search</a></li>
<li><a href="https://blog.dich.bid/weekly">weekly</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">github</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post">
<h1 class="post-title"><a href="https://blog.dich.bid/windows-sde/">乱七八糟:Windows开发环境搭建</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2024-10-04
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/windows/">#Windows</a>&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 刚刚拿到windows的小伙伴可能对开发环境比较陌生这里对常用的开发环境设置进行总结。</p>
<span id="continue-reading"></span>
<p>首先我们默认windows版本为win11 23H2 专业工作站版,可以查看<a href="https://blog.dich.bid/windows-optimization/">上一期博客</a>.</p>
<h2 id="da-jian-wslhuan-jing">搭建WSL环境</h2>
<p>适用于 Linux 的 Windows 子系统 (WSL) 可让开发人员直接在 Windows 上按原样运行 GNU/Linux 环境,例如 Ubuntu、OpenSUSE、Kali、Debian、Arch Linux 等,并直接在 Windows 上使用 Linux 应用程序、实用程序和 Bash 命令行工具,不用进行任何修改,也无需承担传统虚拟机或双启动设置的开销。</p>
<p>首先,我们需要在<code>控制面板-&gt;程序-&gt;启用或关闭Windows功能</code>选中适用于Linux的Windows子系统和虚拟机平台容器以及hyper-v待安装完成后重启电脑。</p>
<p>然后,在<code>管理员模式下打开 PowerShell 或 Windows 命令提示符</code>,方法是右键单击并选择“以管理员身份运行”,输入以下命令,然后重启计算机。</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>wsl --install
</span></code></pre>
<p>此命令将启用运行 WSL 并安装 Linux 的 Ubuntu 发行版所需的功能。(可以更改此默认发行版)。</p>
<h3 id="yi-xie-qi-ta-ming-ling">一些其他命令</h3>
<p><strong>列出可用的 Linux 发行版</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>wsl --list --online
</span></code></pre>
<p><strong>列出已安装的 Linux 发行版</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>wsl --list --verbose
</span></code></pre>
<p><strong>更新 WSL</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>wsl --update
</span></code></pre>
<p><strong>检查 WSL 状态</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>wsl --status
</span></code></pre>
<p><strong>关闭</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>wsl --shutdown
</span></code></pre>
<p>立即终止所有正在运行的发行版和 WSL 2 轻量级实用工具虚拟机。 在需要重启 WSL 2 虚拟机环境的情形下,例如更改内存使用限制或更改 .wslconfig 文件,可能必须使用此命令。</p>
<p><strong>导出分发版</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>wsl --export &lt;Distribution Name&gt; &lt;FileName&gt;
</span></code></pre>
<p>将指定分发版的快照导出为新的分发文件。 默认为 tar 格式。 在标准输入中,文件名可以是 -。 选项包括:</p>
<p>--vhd指定导出分发版应为 .vhdx 文件而不是 tar 文件(这仅在使用 WSL 2 的情况下受支持)</p>
<p><strong>导入分发版</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>wsl --import &lt;Distribution Name&gt; &lt;InstallLocation&gt; &lt;FileName&gt;
</span></code></pre>
<p>导入指定的 tar 文件作为新的分发版。 在标准输入中,文件名可以是 -。 选项包括:</p>
<p>--vhd指定导入分发版应为 .vhdx 文件而不是 tar 文件(这仅在使用 WSL 2 的情况下受支持)
--version &lt;1/2&gt;:指定将分发版导入为 WSL 1 还是 WSL 2 分发版</p>
<h2 id="da-jian-xu-ni-ji-huan-jing">搭建虚拟机环境</h2>
<p>这里以 VMware Workstation Pro v17.6.0 为例该软件支持安装包括windows/linux/macos等多种虚拟机。</p>
<p>首先下载 <a href="https://www.423down.com/14542.html">Vmware</a>,随后安装并<a href="https://www.ypojie.com/6066.html">激活</a>,然后提前下载好所需系统的镜像,这里推荐<a href="https://help.mirrorz.org/">整合镜像站</a>并在Vmware中启动。</p>
<h2 id="da-jian-docker">搭建Docker</h2>
<p>在 Windows 上部署 Docker 的方法是先安装一个虚拟机,并在安装 Linux 系统的的虚拟机中运行 Docker。</p>
<p>我们需要先开启 Hyper-V 方法和搭建WSL一样 也可以通过命令来启用 Hyper-V ,请右键开始菜单并以管理员身份运行 PowerShell执行以下命令</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
</span></code></pre>
<p>然后安装Docker这里提供了一个图形安装界面<a href="https://docs.docker.com/desktop/install/windows-install/">Docker Desktop</a></p>
<p>安装时如果你想使用WSL作为后端则可以勾选 <code>Use WSL2 instead of Hyper-V</code>随后可以登录docker账号并换源等等。</p>
<h2 id="shi-yong-unigetuiguan-li-ruan-jian-bao">使用UniGetUI管理软件包</h2>
<p>众所周知windows下包管理向来是个老大难问题各个软件包来源分散难以统一更新环境部署的包比较复杂这里推荐使用<a href="https://github.com/marticliment/UniGetUI">UniGetUI</a>来统一管理。原名wingetUI</p>
<ul>
<li>WingetUI 能够安装、更新和卸载 Winget包括 Microsoft Store、Scoop、Chocolatey、pip、npm 和 .NET Tool 中的软件包。</li>
<li>WingetUI 还会检测您手动安装的应用程序是否可以更新!
它还可以升级和卸载以前安装的软件包 - 以及卸载内置的Windows应用程序</li>
<li>WingetUI 能够导入和导出您选择的软件包,以便您将来可以轻松安装它们。</li>
<li>WingetUI 能够在安装前显示软件包相关信息如许可证、SHA256 哈希值、主页等)。</li>
<li>有超过 14000 个可用软件包(如果启用 Winget、Scoop 和 Chocolatey</li>
</ul>
<h2 id="shi-yong-idehe-dai-ma-bian-ji-qi">使用IDE和代码编辑器</h2>
<p><a href="https://www.jetbrains.com.cn/ides/#choose-your-ide">Jetbrains</a>向来是IDE中最知名的一款功能丰富界面美观并具有多种语言支持</p>
<p><a href="https://visualstudio.microsoft.com/zh-hans/">Visual Studio</a>VS是一个基本完整的开发工具集它包括了整个软件生命周期中所需要的大部分工具如UML工具、代码管控工具、集成开发环境(IDE)等等,可完美支持 C#、C++、Python、JavaScript、Node.js、Visual Basic、HTML 等流行的编程语言。</p>
<p><a href="https://github.com/VSCodium/vscodium">VS Codium</a>Visual Studio Code也称为VS Code是一款支持LinuxWindows和macOS的代码编辑器。它既能编辑简单文本也能像集成开发环境IDE一样管理整个代码库。它还可以通过插件进行扩展被广泛认为是一个可靠的文本编辑器轻松打败其他编辑器,而VS Codium是一款开源的Vscode去除了Trakcer和远程报告功能和可能侵犯你隐私的功能。</p>
<h2 id="shi-yong-zhong-duan-gong-ju">使用终端工具</h2>
<p>在开发的时候我们常常遇到需要打开多个终端的情景那么有没有一款工具可以将SSH/WSL/telnet/SFTP/串口通信一网打尽呢?</p>
<p><a href="https://mobaxterm.mobatek.net/download.html">MobaXterm</a>一款功能极其强大的远程连接工具支持SSH、X11转发、串口通信等多种连接方式。它不仅可以用于远程连接Linux服务器还可以模拟多个终端实现多任务并行操作。此外MobaXterm还提供了文件上传下载、终端模拟等实用功能。</p>
<p><a href="https://github.com/electerm/electerm">electerm</a>一款开源跨平台的SSH桌面终端管理软件中文版Electerm 支持全平台 Linuxmacwin它还可以帮助用户将其所有书签主题和快速命令同步到 GitHub secret gist它支持用户使用其文件管理器编辑远程文件执行各种与终端相关的文件同时还支持 SSH 和 SFTP 网络协议。</p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/awesome-360t7/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">综合工程:360T7刷ImmortalWrt</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/about-2024/">
<span class="button__text">乱七八糟:2024年度总结</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep">:: </span>
Theme: <a href="https://github.com/pawroman/zola-theme-terminimal/">Terminimal</a> by pawroman
</span>
</div>
</div>
</footer>
</div>
</body>
</html>