本文介绍了nuget.exe更新为新的csproj格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从命令行更新某些项目的nuget引用.这些项目使用包括PackageReference元素的新格式.我正在使用的命令是:

I am trying to update the nuget references of some projects from the command line. These projects use the new format which include PackageReference elements. The command I am using is:

nuget.exe update someproj.csproj

这会导致错误:

是否可以使用nuget.exe或dotnet.exe从命令行更新软件包?

Is there some way to use nuget.exe or dotnet.exe to update packages from the command line?

推荐答案

您将需要nuget.exe> = 4版本才能使用新的csproj格式.

You will need version >= 4 of nuget.exe to work with the new csproj format.

但是您仍然需要使用旧样式packages.config,否则您将获得以下输出

However you will still need to use the old style packages.config or you will get the following output

C:\dev>nuget.exe update test.csproj
MSBuild auto-detection: using msbuild version '15.1.548.43366' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\bin'.
Unable to update. The project does not contain a packages.config file.

但是,您也许可以使用powershell Commandlet

However you might be able to use the powershell commandlets

Update-Package

这些可以从程序包管理器控制台中运行( https ://docs.microsoft.com/zh-cn/nuget/tools/package-manager-console ).

These can be run from the package manager console (https://docs.microsoft.com/en-us/nuget/tools/package-manager-console).

您也可以只加载powershell模块并执行以下操作

You can also just load in the powershell module and execute the following

Import-Module PackageManagement.Cmdlets.dll

Set-Project MySolution "MySolution.sln"

Update-Package

有关此问题的更多信息,请参见此博客- http://community.sharpdevelop.net/blogs/mattward/archive/2011/06/12/InstallingNuGetPackagesOutsideVisualStudio.aspx

more information on this can be found on this blog - http://community.sharpdevelop.net/blogs/mattward/archive/2011/06/12/InstallingNuGetPackagesOutsideVisualStudio.aspx

这篇关于nuget.exe更新为新的csproj格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 00:26
查看更多