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 版本

下載 Rider 到 WSL,第一次下載會花比較多時間

最後會開啟 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 一樣,就不再贅述了。
心得
JetBrains Gateway 提供了整合遠端伺服器的功能,讓我可以更快速的知道遠端環境會發生甚麼事,如果你像我一樣開發環境是 Windows,但是又要交付 Docker Image,目前這種方式是不錯的選擇。
若有謬誤,煩請告知,新手發帖請多包涵
Microsoft MVP Award 2010~2017 C# 第四季
Microsoft MVP Award 2018~2022 .NET