Nuget-Install-Package : The specified path, file name, or both are too long

Problem

Today, I have downloaded a graph api sample project from Microsoft site, then opened the project solution from Downloads folder, now I am receiving the build error ‘The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters‘.

Then I have tried to download the file ‘Microsoft.IdentityModel.Clients.ActiveDirectory.dll’ by using Package Manager Console. But I got the same error.

PM> Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory -Version 1.0.3
Install-Package : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
At line:1 char:16
+ Install-Package <<<<  Microsoft.IdentityModel.Clients.ActiveDirectory -Version 1.0.3
    + CategoryInfo          : NotSpecified: (:) [Install-Package], PathTooLongException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

Solution

After analyzed some time, find my project path is long enough that when the package is installed, adding the package folder fails because it reached the
qualified name length limit.

My actual project path:

C:UsersAdministratorDownloadsgrapghapi-active-directory-dotnet-webapi-onbehalfofactive-directory-dotnet-webapi-onbehalfof-master

The above path is too long and it reached the qualified name length limit. So, I have renamed the project folder name and moved project folder from Downloads
folder to C Drive.

My new project path:

C:graph-api-sample

Now, the too long path problem solved for me.

Advertisement

2 thoughts on “Nuget-Install-Package : The specified path, file name, or both are too long”

Leave a Comment