2

I am working on an ASP.NET Web API 2 project with .NET target framework 4.6.1. I am trying to setup github workflow for my repo. When the dotnet restore command is run, it throws an error like below.

enter image description here

I am getting the same error if I run the same command in from command prompt inside my project. Also if I run dotnet build, it shows below error.

enter image description here

The project builds fine from Visual Studio but not working from command line or github workflow yml. Can anyone please point me on what am I missing?

Setu Kumar Basak
  • 11,460
  • 9
  • 53
  • 85

2 Answers2

1

DOTNET Restore does not support pacakges.config https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-restore

enter image description here

So you have to move the nuget package references to csproj file itself

Here is a great comment on how to do that https://stackoverflow.com/a/65701746/8318698

Note: check that if multiple projectGuid is there on csproj at the end of the steps

After that you will be able to use dotnet restore without a hitch.

0

The project builds fine from Visual Studio but not working from command line

Check which sln file Visual Studio is using to build your project.
Since I don't see any sln/csproj in your GitHub repository, it is also possible that you have a .gitignore which would prevent adding those in the first place.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    My sln file and csproj file is both in my Github repository under the celt2/API directory. https://github.com/Team-Glare/CELT2/blob/main/celt2/API/CELTAPI.sln https://github.com/Team-Glare/CELT2/blob/main/celt2/API/CELTAPI/CELTAPI.csproj – Setu Kumar Basak Sep 21 '21 at 14:11
  • @SetuKumarBasak OK, I must have missed them before. – VonC Sep 21 '21 at 14:55