使用 Jetbrains Rider Remote Development 开发 .NET Core 应用程式

Jetbrains Rider Remote Development 是 Jetbrains 旗下的产品,可以透过 Jetbrains Toolbox 独立安装,也可以直接透过 Jetbrains Rider 使用,这个功能主要就是让 Windows 的用户可以在 WSL (Ubuntu) 环境下开发、中断、除错。

 

开发环境

  • Windows 11 Home
  • WSL2 + Ubuntu-24.04
  • Jetbrains Rider 2024.3.6

开始之前要先装好 WSL,参考这里

https://dotblogs.com.tw/yc421206/2025/02/23/installing_docker_on_windows_wsl

在 WSL2 的 Ubuntu 24.04 中安装 .NET Core 8 SDK

更新系统套件,执行以下指令:

sudo apt update && sudo apt upgrade -y

 

执行以下指令安装 .NET 8 SDK:

sudo apt install -y dotnet-sdk-8.0

 

执行以下指令确认安装是否成功:

dotnet --version

 

建立一个简单的 .NET Console 应用来测试:

dotnet new console -o MyApp
cd MyApp
dotnet run

你应该会看到以下输出:
Hello, World!

 

Jetbrains Rider Remote Development For WSL2

开启 Rider

 

选择 Gateway 版本

 

第一次下载会花比较多时间

 

最后会开启 Jetbrains Client for Jetbrains Rider 

 

这是透过  JetBrains Gateway - Remote Development for JetBrains IDEs  所执行的,画面如下图:

 

Jetbrains Client for Jetbrains Rider 多了 WSL 的资讯

 

为了要观察作业系统的版本,增加以下程式码

Console.WriteLine("Hello, World!");
Console.WriteLine($"作业系统描述: {RuntimeInformation.OSDescription}");
Console.WriteLine($"作业系统架构: {RuntimeInformation.OSArchitecture}");
Console.WriteLine($"进程架构: {RuntimeInformation.ProcessArchitecture}");
Console.WriteLine($"作业系统版本: {Environment.OSVersion}");
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
   Console.WriteLine("作业系统: Windows");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
   Console.WriteLine("作业系统: Linux");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
   Console.WriteLine("作业系统: macOS");
}
else
{
   Console.WriteLine("作业系统: 未知");
}
Console.ReadLine();

 

执行结果如下,可以看到应用程式在 Linux 执行了

 

Jetbrains Rider Remote Development For SSH

在 WSL 安装  SSH

更新软体包清单并安装 OpenSSH Server:

sudo apt update
sudo apt install openssh-server -y

 

启动并设定 OpenSSH Server 开机自动启动:

sudo service ssh start
sudo systemctl enable ssh

 

确认 SSH Server 状态:

sudo service ssh status

 

 

显示 WSL IP

下列方法择一

echo "Your WSL2 IP is: $(hostname -I | awk '{print $1}')"

 

ip addr show eth0

 

使用 SSH 的操作步骤

 

用 SSH 登入 WSL

 

 

执行结果就跟 WSL 一样,就不再赘述了。

若有谬误,烦请告知,新手发帖请多包涵


Microsoft MVP Award 2010~2017 C# 第四季
Microsoft MVP Award 2018~2022 .NET

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章

5 点赞(415) 阅读(67)