NuGet/Home

invalid paths in configuration files should report actionable error message

Open

#9,766 创建于 2020年7月8日

在 GitHub 查看
 (3 评论) (0 反应) (0 负责人)HTML (292 fork)batch import
Area:SettingsFunctionality:RestoreIcebox cleanup candidatePriority:3Status:InactiveType:Bughelp wanted

仓库指标

Star
 (1,459 star)
PR 合并指标
 (平均合并 464天 23小时) (30 天内合并 1 个 PR)

描述

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.

贡献者指南