NuGet/Home

invalid paths in configuration files should report actionable error message

Open

#9.766 aberto em 8 de jul. de 2020

Ver no GitHub
 (3 comments) (0 reactions) (0 assignees)HTML (292 forks)batch import
Area:SettingsFunctionality:RestoreIcebox cleanup candidatePriority:3Status:InactiveType:Bughelp wanted

Métricas do repositório

Stars
 (1.459 stars)
Métricas de merge de PR
 (Mesclagem média 464d 23h) (1 fundiu PR em 30d)

Description

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:

  • better error messages when unable to load file
    • however, I believe the path being walked is ..\, so it's hard to give a good, actionable error message from NuGet.Configuration
  • msbuild restore uses the SolutionDir property, only needed for packages.config projects, even when RestorePackagesConfig=true is not used.
  • msbuild restore of packages.config projects can't handle SolutionDir being a relative path, which is what NuGet itself added to the project file when using the "Enable NuGet Package Restore" command, only available in VS2010 to VS2012.

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. [<path_to_proj>\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.

Guia do colaborador