Add Linux build script and documentation

This PR adds a Linux build script (build-linux.sh) that allows building the v2rayN application on Linux systems. It also includes documentation (BUILD-LINUX.md) on how to use the script.

Note: The documentation needs to be manually migrated to the Wiki.
This commit is contained in:
FlowerRealm 2025-09-24 14:03:07 +08:00
parent 6b85aa0b03
commit 364aa56cd4
3 changed files with 87 additions and 0 deletions

3
.gitignore vendored
View file

@ -399,3 +399,6 @@ FodyWeavers.xsd
# JetBrains Rider # JetBrains Rider
.idea/ .idea/
*.sln.iml *.sln.iml
# Add IFLOW.md to gitignore
IFLOW.md

54
v2rayN/BUILD-LINUX.md Normal file
View file

@ -0,0 +1,54 @@
# Linux构建指南
本文档介绍了如何在Linux系统上构建v2rayN应用程序。
## 构建脚本
项目提供了一个专门的构建脚本 `build-linux.sh`,位于 `v2rayN/` 目录下。该脚本会执行以下操作:
1. 还原所有项目的NuGet包依赖
2. 构建所有项目ServiceLib、GlobalHotKeys和v2rayN.Desktop
3. 发布自包含的Linux应用程序到 `publish/v2rayN-linux-64/` 目录
## 系统要求
- Ubuntu/Debian或其他基于Debian的Linux发行版
- 已安装 .NET 8.0 SDK
- Git用于获取源代码和子模块
## 构建步骤
1. 确保已安装 .NET 8.0 SDK
```bash
dotnet --version
```
2. 进入项目目录:
```bash
cd v2rayN
```
3. 运行构建脚本:
```bash
./build-linux.sh
```
4. 构建完成后,可执行文件位于:
```
./publish/v2rayN-linux-64/v2rayN
```
5. 直接运行应用程序:
```bash
./publish/v2rayN-linux-64/v2rayN
```
## 注意事项
- 构建脚本会自动处理子模块的初始化
- 构建过程可能需要几分钟时间,具体取决于系统性能
- 生成的可执行文件是自包含的,不依赖系统上的其他库
- 如果遇到权限问题,请确保构建脚本具有执行权限:
```bash
chmod +x build-linux.sh
```

30
v2rayN/build-linux.sh Executable file
View file

@ -0,0 +1,30 @@
#!/bin/bash
# v2rayN Linux构建脚本仅生成可执行文件
set -e # 遇到错误时停止执行
# 还原NuGet包
echo "正在还原NuGet包..."
dotnet restore ./v2rayN.Desktop/v2rayN.Desktop.csproj
dotnet restore ./ServiceLib/ServiceLib.csproj
dotnet restore ./GlobalHotKeys/src/GlobalHotKeys/GlobalHotKeys.csproj
# 构建项目
echo "正在构建项目..."
dotnet build ./ServiceLib/ServiceLib.csproj --configuration Release
dotnet build ./GlobalHotKeys/src/GlobalHotKeys/GlobalHotKeys.csproj --configuration Release
dotnet build ./v2rayN.Desktop/v2rayN.Desktop.csproj --configuration Release
# 发布应用
echo "正在发布应用..."
OUTPUT_DIR="./publish"
mkdir -p $OUTPUT_DIR
# 发布Desktop版本仅生成可执行文件
echo "发布Desktop版本..."
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r linux-x64 --self-contained true -o $OUTPUT_DIR/v2rayN-linux-64
echo "构建完成!"
echo "可执行文件位于: ./publish/v2rayN-linux-64/"
echo "直接运行: ./publish/v2rayN-linux-64/v2rayN"