我有一个包含 2 个项目的 Visual Studio 2017 解决方案。一个项目使用 .NET 4.7.1。另一个项目使用 .NET Core。我对在 VSTS 中自动构建我的 .NET 4.7.1 项目很感兴趣。但是,此时,我的构建失败并显示以下错误:
The nuget command failed with exit code(1) and error(System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: Cannot determine the packages folder to restore NuGet packages. Please specify either -PackagesDirectory or -SolutionDirectory.
at NuGet.CommandLine.RestoreCommand.GetPackagesFolder(PackageRestoreInputs packageRestoreInputs)
at NuGet.CommandLine.RestoreCommand.<PerformNuGetV2RestoreAsync>d__35.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.CommandLine.RestoreCommand.<ExecuteCommandAsync>d__30.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at NuGet.CommandLine.Command.Execute()
at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)
---> (Inner Exception #0) System.InvalidOperationException: Cannot determine the packages folder to restore NuGet packages. Please specify either -PackagesDirectory or -SolutionDirectory.
at NuGet.CommandLine.RestoreCommand.GetPackagesFolder(PackageRestoreInputs packageRestoreInputs)
at NuGet.CommandLine.RestoreCommand.<PerformNuGetV2RestoreAsync>d__35.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.CommandLine.RestoreCommand.<ExecuteCommandAsync>d__30.MoveNext()<---)
Packages failed to restore
此故障发生在我的 VSTS 构建管道中的第一个任务期间。该任务使用以下属性定义:
Command: restore
Path to solution, packages.config, or project.json: MyNet471Project/MyNet471Project.csproj
Feeds to use: Feed(s) I select here - <My Private NuGet repo>
Disable local cache is not checked
我不明白为什么我会遇到这个问题。我错过了什么?
更新 值得注意的是,我已经删除了解决方案级别的“packages”目录和本地机器上的“bin”目录。当我在 Visual Studio 中重建解决方案时,Visual Studio 会自动获取包并成功构建。
但是,如果我从命令行运行,则会nuget restore MyNet471Project/MyNet471Project.csproj
收到与我在 VSTS 中看到的错误类似的错误。命令行中的错误说:
Cannot determine the packages folder to restore NuGet packages. Please specify either -PackagesDirectory or -SolutionDirectory.
Visual Studio 运行什么来自动还原包?
我为“目标目录”属性添加了一个值并且它起作用了!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句