简体   繁体   English

如何通过 CLI 更新 UWP 项目的 nuget 包?

[英]How do I update UWP projects' nuget packages via the CLI?

All .NET framework projects that use Nuget have a packages.config per project.所有使用 Nuget 的 .NET 框架项目每个项目都有一个 packages.config。 When I run something like:当我运行类似的东西时:

nuget update MySolution.sln -Id PackageName -Version 1.2.3

It will update all projects in my solution that use this package to the specified version (1.2.3 in this case)它会将我的解决方案中使用此包的所有项目更新到指定版本(在本例中为 1.2.3)

However, I'm finding that this does NOT work for UWP projects.但是,我发现这不适用于 UWP 项目。 UWP does not use packages.config and instead put the package references directly into the csproj file. UWP 不使用packages.config,而是将包引用直接放入csproj 文件中。 As a result, this is literally what nuget update says when I run it:结果,这就是我运行 nuget update 时所说的:

Found 2 projects with a packages.config file. (A.csproj, B.csproj)

where A and B are my .NET Framework projects that still have a packages.config file.其中 A 和 B 是我的 .NET Framework 项目,它们仍然有一个 packages.config 文件。 But this list doesn't include my new UWP projects.但此列表不包括我的新 UWP 项目。

Is there another command for nuget update that will work with UWP projects?是否有另一个适用于 UWP 项目的 nuget 更新命令?

How do I update UWP projects' nuget packages via the CLI?如何通过 CLI 更新 UWP 项目的 nuget 包?

This is a known issue for the packagereference .这是packagereference一个已知问题。 At the moment, NuGet CLI does not support automatic package updates to the the new .NET Core .csproj format, you can refer to the below GitHub issue for details:目前,NuGet CLI 不支持对新的 .NET Core .csproj格式的自动包更新,您可以参考以下 GitHub 问题了解详细信息:

support for updating references into csproj from commandline(s)支持从命令行更新对 csproj 的引用

Besides, as test, the workaround using following command line does not work with UWP project此外,作为测试,使用以下命令行的解决方法不适用于 UWP 项目

dotnet add package <PackageName> --version <version>

Indeed, currently it is very inconvenient to manage packages outside of Visual Studio for UWP with packagereference .事实上,目前Visual Studio for UWP 之外使用packagereference管理包非常不方便。

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM