PublishAotCross.LinuxToWin 1.0.0

dotnet add package PublishAotCross.LinuxToWin --version 1.0.0
                    
NuGet\Install-Package PublishAotCross.LinuxToWin -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PublishAotCross.LinuxToWin" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PublishAotCross.LinuxToWin" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="PublishAotCross.LinuxToWin" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PublishAotCross.LinuxToWin --version 1.0.0
                    
#r "nuget: PublishAotCross.LinuxToWin, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PublishAotCross.LinuxToWin@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PublishAotCross.LinuxToWin&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=PublishAotCross.LinuxToWin&version=1.0.0
                    
Install as a Cake Tool

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 的交叉编译。

先决条件

在开始之前,您需要确保环境中已安装以下依赖项:

  1. LLVM/lld: 确保 lld-link 命令可用。
  2. msvc-wine: 提供交叉编译所需的 Windows SDK与环境变量。
在 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 指南进行安装或下载。

使用步骤

  1. 向您的项目添加 NuGet 包引用。

    dotnet add package PublishAotCross.LinuxToWin
    
  2. 可选:配置 msvc-wine 路径。

    本包会默认在 /opt/msvc 路径下寻找 msvc-wine。如果您的安装路径不同,请在 .csproj 项目文件中添加 MSVCWineBinPath 属性来指定正确的 bin 目录路径。

    <PropertyGroup>
    
      <MSVCWineBinPath>/path/to/your/msvc/bin</MSVCWineBinPath>
    </PropertyGroup>
    
  3. 发布您的 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:

  1. LLVM/lld: Make sure the lld-link command is available.
  2. 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

  1. Add the NuGet package reference to your project.

    dotnet add package PublishAotCross.LinuxToWin
    
  2. Optional: Configure the msvc-wine path.

    This package defaults to searching for msvc-wine in the /opt/msvc path. If your installation path is different, please add the MSVCWineBinPath property in your .csproj project file to specify the correct bin directory path.

    <PropertyGroup>
    
      <MSVCWineBinPath>/path/to/your/msvc/bin</MSVCWineBinPath>
    </PropertyGroup>
    
  3. Publish your Native AOT application.

    Execute the dotnet publish command, specifying the Windows platform RID (win-x64).

    dotnet publish -r win-x64 -c Release
    
There are no supported framework assets in this package.

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