我正在发布 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:
- 请参阅 https://learn.microsoft.com/en-us/nuget/install-nuget-client-tools 上的说明(命令行版本)
对于内部 VS https://www.nuget.org/packages/NuGet.VisualStudio - 在 VS 的“包管理器”窗口中运行以下命令:
Install-Package NuGet.VisualStudio -Version 4.5.0
关于visual-studio - Nuget 发布错误 : Failed to process request. 'A client version ' 4.1.0',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48483733/