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.
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.
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?
2
Answers
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.DOTNET Restore does not support pacakges.config https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-restore
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.