When trying to install the NuGet Package RestSharp I get the error The path is not of a legal form
and the package is not installed.
When installing from the console using Install-Package RestSharp
, there are a lot of the following messages:
The item
C:\Users\myName\Source\Workspaces\Project\Solution\packages\RestSharp.105.1.0\lib\net35\RestSharp.dll
could not be found in your workspace, or you do not have permission to
access it.
This happens with the newly released Visual Studio 2015 (community edition).
Edit: If you have NuGet 3.0, then that's the problem. Just update NuGet and everything should work. The steps below apply to NuGet 3.0, which are painful and error prone. Don't go through such pain, choose the easy step, update your Nuget!
I updated to VS Express 2015 and since then i've been through some adventures.
TL;DR if you "disable" TFS (source control), you should be able to install the package. Then add the solution to source control again, but it caused me tons of problems.
So...
I see you have TFS. I have it too.
Also, I see you are getting the same error messages as me.
I tried to install LanguageExt (an awesome library for C# 6) and it failed when it tried to install one of its dependencies (System.Collections.Immutable).
If you want to go through all this things, please make a backup of your project folder.
This is what I did:
1 - Copied my solution folder to somewhere else.
2 - Opened the solution. VS smartly asked me to add it to source control, but I didn't want to.
3 - Tried to Install-Package LanguageExt
4 - Unexpected success!
5 - "Fine, let me just add it to the TFS source control again"
Here my journey started.
Since I have little experience with TFS, I got thousands and thousands of conflicts, files vanishing and appearing again, etc.
But after some work, I got it running.
And it was worth it.
But the solution isn't large, so, it was easy.
Had the same problem with the packages below, updated NuGet via "Tools -> Extensions and Updates -> Updates" to v.3.1.1.0 and now everything works again. Thanks!
Microsoft.Bcl
Google.Apis.Calendar.v3
RazorEngine
Sample error so more people can find this thread:
"Install-Package : The path is not of a legal form.
At line:1 char:16
+ Install-Package <<<< RazorEngine
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand"
Had a same problem with my VS 2015, I just added the reference via nuget by opening the same solution in VS 2013 and then reopened it back in VS 2015 for usual work.
I had this happen on version 3.5.0.1484 of the nuget package manager. In my case a merge from a dev branch altered a packages.config file to list a version of a package that was no longer present. Any attempt to use one of the package commands in the Package Manager Console after loading the solution failed with the The Path is not of a legal form. error. I ended up using the solution level gui to consolidate on the affected packages and that resolved the error. Likely I could have just reverted the packages.config file as well.
Please add an entry in package.config manully as given below and build the solution. This works for me.
I had the same issue in VS 2017, with another package (WPFLocalizeExtension).
The way to solve that was to delete .nuget folder from the project, then go to .csproj project file, and delete the following lines:
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
After that (and after trying all the existing solutions into the whole world), I rebuilded the project nad the program runs succesful and works perfect.
It's really incredible the bugs of nugget repository....you need some kind of magic to solve in each specific case, it's terrible.
Hope this solution helps anyone.