Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error "dotnet : Could not find any project in `C:\**." when running "dotnet add package Microsoft.AspNetCore.Authentication.MicrosoftAccount"

I have visual studio 2019 and i created a new asp.net core 2.2 project. now i am following these steps Configure Microsoft Account Authentication to enable external login to our web application. but when i run this command:-

dotnet add package Microsoft.AspNetCore.Authentication.MicrosoftAccount

i got this error:-

PM> dotnet add package Microsoft.AspNetCore.Authentication.MicrosoftAccount dotnet : Could not find any project in C:\Users\*****\source\repos\MSlogintest\. At line:1 char:1 + dotnet add package Microsoft.AspNetCore.Authentication.MicrosoftAccount + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (Could not find ...\MSlogintest`.:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError Usage: dotnet add package [options]

Arguments: The project file to operate on. If a file is not specified, the command will search the current directory for one. The package reference to add.

Options: -h, --help Show command line help. -v, --version The version of the package to add. -f, --framework Add the reference only when targeting a specific framework. -n, --no-restore
Add the reference without performing restore preview and compatibility check. -s, --source The NuGet package source to use during the restore. --package-directory The directory to restore packages to. --interactive
Allows the command to stop and wait for user input or action (for example to complete authentication).

as follow:- enter image description here

and when i access the folder, i found that there is a VS project folders, as follow:- enter image description here

so why the error is saying that it can not find any project? can anyone advice on this error please? Thanks

like image 488
John John Avatar asked May 09 '19 14:05

John John


2 Answers

I encountered the same issue and found the fix. First of all, read the error message completely and carefully. It says:

"Could not find any project ...."

Which means it was expecting the project information. If you further watch the message closely, it has mentioned the correct usage of this command i.e.

Usage: dotnet add <PROJECT> package [options] <PACKAGE_NAME>

In the argument, enter your project name and run it again. This time, you should see the success message similar to:

info : Adding PackageReference for package 'Microsoft.xxxxxxxx.xxxxxxxx' into project 'C:\Users\xxx\source\repos\ProjectFolder\xxxxxxxx.csproj'.

demonstration of the error and the fix

like image 138
Saima Avatar answered Sep 17 '22 22:09

Saima


Got this working on powershell (no IDE). The solution was somewhere hidden in the comments but here is the easy one:

dotnet add <project> package <packageName>

In this case I believe it would be:

dotnet add ContosoUniversity package Microsoft.AspNetCore.Authentication.MicrosoftAccount

like image 31
Lucas Serafim Avatar answered Sep 16 '22 22:09

Lucas Serafim