Error occurred while restoring NuGet packages: System.ArgumentException: The path is not of a legal form.

Topics: Ecosystem
Jan 21, 2014 at 12:09 AM
I should probably ask this on a Visual Studio forum, but since it's highly nuget-specific I thought I might get a better answer here.

I have disabled automatic package restore in Package Manager Settings in Visual Studio. However, every time I try to compile a project where I haven't yet saved the SLN file (e.g.., the first time after creating it, before the SLN is saved, or when I delete the SLN manually), I get the following error:

Error occurred while restoring NuGet packages: System.ArgumentException: The path is not of a legal form.
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetDirectoryName(String path)
at NuGet.VisualStudio.VsUtility.GetNuGetSolutionFolder(Solution solution)
at NuGet.VsEvents.PackageRestorer.UsingOldPackageRestore(Solution solution)
at NuGet.VsEvents.PackageRestorer.BuildEvents_OnBuildBegin(vsBuildScope Scope, vsBuildAction Action).
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========

It seems like the package restorer code runs even when package restore is not enabled.