PublishAotCross.LinuxToWin
1.0.0
dotnet add package PublishAotCross.LinuxToWin --version 1.0.0
NuGet\Install-Package PublishAotCross.LinuxToWin -Version 1.0.0
<PackageReference Include="PublishAotCross.LinuxToWin" Version="1.0.0" />
<PackageVersion Include="PublishAotCross.LinuxToWin" Version="1.0.0" />
<PackageReference Include="PublishAotCross.LinuxToWin" />
paket add PublishAotCross.LinuxToWin --version 1.0.0
#r "nuget: PublishAotCross.LinuxToWin, 1.0.0"
#:package PublishAotCross.LinuxToWin@1.0.0
#addin nuget:?package=PublishAotCross.LinuxToWin&version=1.0.0
#tool nuget:?package=PublishAotCross.LinuxToWin&version=1.0.0
PublishAotCross.LinuxToWin
<a id="chinese"></a>
中文 | English
这是一个 NuGet 包,内置了 MSBuild 目标,旨在帮助 .NET 开发者在 Linux 环境下交叉编译原生AOT (Native AOT)项目到 Windows 平台。它可以解决在 Linux 上直接发布 Windows 目标时遇到的链接器和 SDK 缺失问题。
本项目利用 LLVM/lld 和 msvc-wine 来提供必要的链接器和 Windows SDK,从而实现从 linux 到 win 的交叉编译。
先决条件
在开始之前,您需要确保环境中已安装以下依赖项:
在 Arch Linux 上安装依赖 (示例)
如果您正在使用 Arch Linux,可以通过 AUR 助手 (例如 yay 或 paru) 轻松安装:
# 使用 yay
yay -S lld msvc-wine-git
# 或者使用 paru
paru -S lld msvc-wine-git
对于其他 Linux 发行版,请使用您的包管理器安装 lld,并根据 msvc-wine 指南进行安装或下载。
使用步骤
向您的项目添加 NuGet 包引用。
dotnet add package PublishAotCross.LinuxToWin可选:配置 msvc-wine 路径。
本包会默认在
/opt/msvc路径下寻找msvc-wine。如果您的安装路径不同,请在.csproj项目文件中添加MSVCWineBinPath属性来指定正确的bin目录路径。<PropertyGroup> <MSVCWineBinPath>/path/to/your/msvc/bin</MSVCWineBinPath> </PropertyGroup>发布您的 Native AOT 应用。
执行
dotnet publish命令,并指定 Windows 平台的 RID (win-x64)。dotnet publish -r win-x64 -c Release
<a id="english"></a>
English | 中文
This is a NuGet package with built-in MSBuild targets, designed to help .NET developers cross-compile Native AOT projects from a Linux environment to the Windows platform. It resolves issues with missing linkers and SDKs encountered when directly publishing to a Windows target from Linux.
This project utilizes LLVM/lld and msvc-wine to provide the necessary linker and Windows SDK, enabling cross-compilation from linux to win.
Prerequisites
Before you begin, ensure that the following dependencies are installed in your environment:
LLVM/lld: Make sure thelld-linkcommand is available.msvc-wine: Provides the Windows SDK and environment variables required for cross-compilation.
Installing Dependencies on Arch Linux (Example)
If you are using Arch Linux, you can easily install them via an AUR helper (e.g., yay or paru):
# Using yay
yay -S lld msvc-wine-git
# Or using paru
paru -S lld msvc-wine-git
For other Linux distributions, please use your package manager to install lld and follow the msvc-wine guide to install or download it.
Usage Steps
Add the NuGet package reference to your project.
dotnet add package PublishAotCross.LinuxToWinOptional: Configure the msvc-wine path.
This package defaults to searching for
msvc-winein the/opt/msvcpath. If your installation path is different, please add theMSVCWineBinPathproperty in your.csprojproject file to specify the correctbindirectory path.<PropertyGroup> <MSVCWineBinPath>/path/to/your/msvc/bin</MSVCWineBinPath> </PropertyGroup>Publish your Native AOT application.
Execute the
dotnet publishcommand, specifying the Windows platform RID (win-x64).dotnet publish -r win-x64 -c Release
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 1,154 | 11/2/2025 |