AWS code build restore error NU1100: Unable to resolve for .Net core 3.1

Viewed 969

I have a pipeline on AWS for my api service which written in .Net core 3.1.

My buildspec.yml pretty simple, it runs dotnet restore and dotnet publish.

I get this error in the restore phase "error NU1100: Unable to resolve" for a lot of libraries, for example:

C:\codebuild\tmp\output\src363055303\src\ExternalClient\ExternalClient.csproj : error NU1100: Unable to resolve 'Serilog (>= 2.9.0)' for '.NETCoreApp,Version=v3.1'.

I tried to restore the project on my pc through the terminal using the same command and it works.

I see in the log that the pipeline use nuget org: "Feeds used: https://api.nuget.org/v3/index.json".

This pipeline already worked on AWS, and I have no idea why it started to fail over restore.

2 Answers

You have to install a few things because the machine probably doesn't have VS installed.

Examples bellow use Chocolatey to install things

Nuget

choco install nuget.commandline

MSBuild (in my case I'm using the latest because I'm running on dotnet core 5

choco install visualstudio2019buildtools

Add source to nuget

dotnet nuget add source --name nuget.org https://api.nuget.org/v3/index.json

Configure MSBuildSDKsPath environment variable to point to the dotnet sdk ex: 'C:\Program Files\dotnet\sdk\5.0.202\Sdks\'

After these steps dotnet restore worked without any issues.

After speaking with AWS Support, the issue was the Ec2 image. I was using latest and they suggested that its not the best practise to always use latest. I switched to an older image version and the build is working again.

Related