AWS 代码构建还原错误 NU1100:无法解析 .Net 核心 3.1
AWS code build restore error NU1100: Unable to resolve for .Net core 3.1
我在 AWS 上有一个管道用于我的 api 服务,它是用 .Net core 3.1 编写的。
我的 buildspec.yml 非常简单,它运行 dotnet restore
和 dotnet publish
。
我在很多库的恢复阶段都遇到了这个错误“error NU1100: Unable to resolve”,
例如:
C:\codebuild\tmp\output\src363055303\src\ExternalClient\ExternalClient.csproj : error NU1100: Unable to resolve 'Serilog (>= 2.9.0)' for '.NETCoreApp,Version=v3.1'.
我尝试使用相同的命令通过终端在我的电脑上恢复项目并且它有效。
我在日志中看到管道使用 nuget org:“使用的提要:https://api.nuget.org/v3/index.json"。
此管道已在 AWS 上运行,我不知道为什么它开始故障转移恢复。
你必须安装一些东西,因为机器可能没有安装 VS。
下面的示例使用 Chocolatey 来安装东西
Nuget
choco install nuget.commandline
MSBuild(在我的例子中,我使用的是最新的,因为我在 dotnet core 5运行
choco install visualstudio2019buildtools
将源添加到 nuget
dotnet nuget add source --name nuget.org https://api.nuget.org/v3/index.json
配置MSBuildSDKsPath
环境变量指向dotnet sdk ex:'C:\Program Files\dotnet\sdk.0.202\Sdks\'
完成这些步骤后 dotnet restore
没有任何问题。
在与 AWS Support 交谈后,问题出在 Ec2 映像上。
我使用的是最新版本,他们建议始终使用最新版本并不是最佳做法。
我切换到较旧的图像版本并且构建再次运行。
我在 AWS 上有一个管道用于我的 api 服务,它是用 .Net core 3.1 编写的。
我的 buildspec.yml 非常简单,它运行 dotnet restore
和 dotnet publish
。
我在很多库的恢复阶段都遇到了这个错误“error NU1100: Unable to resolve”, 例如:
C:\codebuild\tmp\output\src363055303\src\ExternalClient\ExternalClient.csproj : error NU1100: Unable to resolve 'Serilog (>= 2.9.0)' for '.NETCoreApp,Version=v3.1'.
我尝试使用相同的命令通过终端在我的电脑上恢复项目并且它有效。
我在日志中看到管道使用 nuget org:“使用的提要:https://api.nuget.org/v3/index.json"。
此管道已在 AWS 上运行,我不知道为什么它开始故障转移恢复。
你必须安装一些东西,因为机器可能没有安装 VS。
下面的示例使用 Chocolatey 来安装东西
Nuget
choco install nuget.commandline
MSBuild(在我的例子中,我使用的是最新的,因为我在 dotnet core 5运行
choco install visualstudio2019buildtools
将源添加到 nuget
dotnet nuget add source --name nuget.org https://api.nuget.org/v3/index.json
配置MSBuildSDKsPath
环境变量指向dotnet sdk ex:'C:\Program Files\dotnet\sdk.0.202\Sdks\'
完成这些步骤后 dotnet restore
没有任何问题。
在与 AWS Support 交谈后,问题出在 Ec2 映像上。 我使用的是最新版本,他们建议始终使用最新版本并不是最佳做法。 我切换到较旧的图像版本并且构建再次运行。