使用GitHub Actions在Ubuntu构建Windows项目遇NU1102错误的解决方法
解决 NU1102: 找不到 Microsoft.NETCore.App.Runtime.win-x64 8.0.19 包的问题
可行解决方案:
1. 显式安装 Windows 目标运行时
在setup-dotnet步骤中添加指定运行时的配置,让Action自动安装win-x64对应的运行时包:
jobs: build: runs-on: ubuntu-latest - name: "⚙ Setup .NET" uses: actions/setup-dotnet@v4 with: dotnet-version: '8.0.x' include-runtimes: win-x64 - name: Restore dependencies run: dotnet restore --runtime win-x64
2. 锁定到已确认可用的.NET版本
若8.0.19版本的运行时包存在同步延迟或缺失问题,可暂时切换到前一个稳定版本:
- name: "⚙ Setup .NET" uses: actions/setup-dotnet@v4 with: dotnet-version: '8.0.18'
3. 指定官方NuGet源进行还原
避免默认源同步问题,在还原步骤中明确指定官方源:
- name: Restore dependencies run: dotnet restore --source https://api.nuget.org/v3/index.json --runtime win-x64
4. 安装跨平台构建依赖(若需)
Ubuntu环境下构建Windows项目,可补充安装必要的跨平台支持组件:
- name: Install cross-build dependencies run: sudo apt-get update && sudo apt-get install -y wine64
内容的提问来源于stack exchange,提问作者Jeremy Thompson
相关产品推荐
相关产品推荐

