NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 253 forks source link

invalid paths in configuration files should report actionable error message #9766

Open zivkan opened 4 years ago

zivkan commented 4 years ago

edit: There are multiple possible issues that could be created after investigating this issue, but I think they're low impact, so possibly not worth tracking separately:


From: https://developercommunity.visualstudio.com/content/problem/959974/vs-2019-165-nuget-package-manager-55-causes-the-pa.html

When the customer runs restore, they are simply getting the error:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets(536,5): error : The path is not of a legal form. [\MyApp.API.csproj]

After getting a binlog, I can see the stack trace:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets(536,5): 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.InternalGetDirectoryName(String path)
   at NuGet.Configuration.Settings.<GetSettingsFilePaths>d__44.MoveNext()
   at NuGet.Configuration.Settings.<GetSettingsFilesFullPath>d__42.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
   at NuGet.Configuration.Settings.LoadSettings(String root, String configFileName, IMachineWideSettings machineWideSettings, Boolean loadUserWideSettings, Boolean useTestingGlobalPath, SettingsLoadingContext settingsLoadingContext)
   at NuGet.Build.Tasks.RestoreSettingsUtils.ReadSettings(String solutionDirectory, String restoreDirectory, String restoreConfigFile, Lazy`1 machineWideSettings, SettingsLoadingContext settingsLoadContext)
   at NuGet.Build.Tasks.GetRestoreSettingsTask.Execute() 

We need to give better, actionable error messages to customers.

zivkan commented 4 years ago

Looking a bit closer, I notice that the command line was a restore of a project, not a solution, and the failure happened in a P2P reference, not the project from the commandline. The P2P project uses packages.config, and it appears that the project file might have defined SolutionDir to ..\. I think this is fundamentally the root cause, but I didn't try to repro it.

jgonz120 commented 3 months ago

This is quite old but we got a feedback ticket where one of the configurations was setup incorrectly. They had the path as empty and were getting "The path is not of legal form" in the output pane when opening the PM UI.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <fallbackPackageFolders>
    <add key="Xamarin Offline Packages" value="" />
  </fallbackPackageFolders>
</configuration>

https://developercommunity.visualstudio.com/t/Not-able-to-use-Nuget-packages-Manager/10685079