nuget.exe更新为新的csproj格式 [英] nuget.exe update with new csproj format

查看:176
本文介绍了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

这会导致错误:

项目的默认XML名称空间必须是MSBuild XML名称空间. 如果项目是以MSBuild 2003格式编写的,请添加 xmlns ="http://schemas.microsoft.com/developer/msbuild/2003" 元素.如果项目是使用旧的1.0或1.2格式创作的, 请将其转换为MSBuild 2003格式.

The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format.

是否可以使用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

有关此问题的更多信息,请参见此博客-

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格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆