visual-studio - Nuget 发布错误 : Failed to process request. 'A client version ' 4.1.0'

标签 visual-studio nuget visual-studio-2017 nuget-package

我正在发布 NuGet 包。我已经安装了最新版本的 Visual Studio 2017 Community。我收到以下错误:

Failed to process request. 'A client version '4.1.0' or higher is required to be able to push packages. Please contact support@nuget.org to get more details.'.

为什么最新的 Visual Studio 不能发布 NuGet?如何解决?完整的构建日志如下:

1>------ Rebuild All started: Project: MyProject.NuGet, Configuration: Release Any CPU ------
1>  MyProject.NuGet -> C:\Users\User\Documents\MyProject\MyProject.NuGet\bin\Release\MyProject.NuGet.dll
1>   
1>  NuGet Packager 2.0.3
1>   
1>  Creating backup...
1>  Renamed MyProject.1.0.6.nupkg to MyProject.1.0.6.nupkg.bak
1>   
1>  Updating NuGet...
1>  The element 'metadata' in namespace 'http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd' has invalid child element 'developmentDependency' in namespace 'http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd'. List of possible elements expected: 'releaseNotes, projectUrl, title, language, iconUrl, dependencies, frameworkAssemblies, tags, references, licenseUrl, summary, copyright, description' in namespace 'http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd'.
1>  Checking for updates from https://nuget.org/api/v2/.
1>  Currently running NuGet.exe 2.2.0.
1>  Updating NuGet.exe to 4.4.1.
1>   
1>  Creating package...
1>  Attempting to build package from 'Package.nuspec'.
1>  Id: MyProject
1>  Version: 1.0.6
1>  Authors: Boris Zinchenko
1>  Description: MyProject
1>  License Url: MyProject
1>  Project Url: MyProject
1>  Tags: MyProject
1>  Dependencies: 
1>  Added file 'lib\net20\MyProject.dll'.
1>  Added file 'tools\init.ps1'.
1>  Added file 'tools\install.ps1'.
1>  Added file 'tools\uninstall.ps1'.
1>  Successfully created package 'MyProject.1.0.6.nupkg'.
1>   
1>  Publishing package...
1>  Repository Url: https://www.nuget.org
1>   
1>  Pushing MyProject 1.0.6 to the NuGet gallery (https://www.nuget.org)...
1>  Failed to process request. 'A client version '4.1.0' or higher is required to be able to push packages. Please contact support@nuget.org to get more details.'. 
1>EXEC : The remote server returned an warning : (400) Bad Request..
1>  Pushing MyProject 1.0.6 to the NuGet gallery (https://www.nuget.org)...
1>  Failed to process request. 'A client version '4.1.0' or higher is required to be able to push packages. Please contact support@nuget.org to get more details.'. 
1>EXEC : The remote server returned an warning : (400) Bad Request..
1>   
1>  Exit Code: 0
1>   
1>  Build Exit Code: -1
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

更新

在@Alexei Levenkov 的宝贵建议之后,我使用命令更新了 NuGet 版本:Install-Package NuGet.VisualStudio。令人惊讶的是,它对我的​​错误没有任何影响,错误仍然存​​在。 NuGet 控制台的更新日志如下。

Package Manager Console Host Version 4.5.0.4685
Type 'get-help NuGet' to see all available NuGet commands.

PM> Install-Package NuGet.VisualStudio

Attempting to gather dependency information for package 'NuGet.VisualStudio.4.5.0' with respect to project 'MyProject', targeting '.NETFramework,Version=v2.0'
Gathering dependency information took 20.7 ms
Attempting to resolve dependencies for package 'NuGet.VisualStudio.4.5.0' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'NuGet.VisualStudio.4.5.0'
Resolved actions to install package 'NuGet.VisualStudio.4.5.0'
Retrieving package 'NuGet.VisualStudio 4.5.0' from 'nuget.org'.
  GET https://api.nuget.org/v3-flatcontainer/nuget.visualstudio/4.5.0/nuget.visualstudio.4.5.0.nupkg
  OK https://api.nuget.org/v3-flatcontainer/nuget.visualstudio/4.5.0/nuget.visualstudio.4.5.0.nupkg 524ms
Installing NuGet.VisualStudio 4.5.0.
Adding package 'NuGet.VisualStudio.4.5.0' to folder 'C:\Users\User\Documents\MyProject\packages'
Added package 'NuGet.VisualStudio.4.5.0' to folder 'C:\Users\User\Documents\MyProject\packages'
Added package 'NuGet.VisualStudio.4.5.0' to 'packages.config'
Successfully installed 'NuGet.VisualStudio 4.5.0' to MyProject
Executing nuget actions took 5.01 sec
Time Elapsed: 00:00:07.1699206

最佳答案

看起来您没有获得更新版本的 NuGet。我假设 VS 附带的版本低于 4.1,听起来 www.nuget.org 现在需要更高版本。

更新 NuGet:

关于visual-studio - Nuget 发布错误 : Failed to process request. 'A client version ' 4.1.0',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48483733/

相关文章:

Python 3,如何设置 Visual Studio C++ 2015 编译器?

IntelliSense 中的 JavaScript 命名空间引用

visual-studio - 正在加载哪个版本的 C 运行时库 (CRT)?

jquery - 通过 Nuget 添加新版本的 Jquery 以及 t4mvc 的问题

visual-studio-2015 - 在 VS2015 中的预构建事件中从 nuget 包文件夹调用可执行文件

visual-studio - Web Compiler 从 less 文件生成一个空的 css

.net - 为什么我的 .NET Standard NuGet 包会触发这么多依赖项?

c# - 如何避免在每个 Controller 中重复一个参数?

c# - 未为迁移的 (project.json -> .csproj) asp.net core 应用程序生成 web.config

c++ - 全局变量影响单元测试结果的问题