[英]Force MSBuild to include the Owners element in the nuget .nuspec file
In my NuGet package creation, I am using the builtin Visual Studio (2019) functionality to create the package.在我的 NuGet package 创建中,我使用内置的 Visual Studio (2019) 功能来创建 package。 I have included the both the
Authors
and Owners
elements in my .csproj
file, but only the Authors
tag gets copied to the final package.我在
.csproj
文件中包含了Authors
和Owners
元素,但只有Authors
标记被复制到最终的 package。 I realize the Owners
element has been deprecated , but Visual Studio still displays that line in the NuGet Package Manager Description, and it would be preferable to have that information be complete (if it's not there, it looks like the package owner was sloppy and left info out that should have been added). I realize the
Owners
element has been deprecated , but Visual Studio still displays that line in the NuGet Package Manager Description, and it would be preferable to have that information be complete (if it's not there, it looks like the package owner was sloppy and left应该添加的信息)。 I can add it back in manually after the package is generated, but that is a hassle.我可以在生成 package 后手动将其重新添加,但这很麻烦。 Can I force that
Owners
element to be added to the NuGet package automatically?我可以强制将该
Owners
元素自动添加到 NuGet package 吗?
Unfortunately not only MSBuild does not support Owners
element but in .nuspec
file the owners
element is also deprecated :不幸的是,不仅 MSBuild 不支持
Owners
元素,而且 在.nuspec
文件中, owners
元素也被弃用了:
Important
重要的
owners is deprecated.
不推荐使用所有者。 Use authors instead.
改用作者。
A comma-separated list of the package creators using profile names on nuget.org.
package 创建者的逗号分隔列表,使用 nuget.org 上的配置文件名称。 This is often the same list as in authors, and is ignored when uploading the package to nuget.org .
这通常与作者中的列表相同,并且在将 package 上传到 nuget.org 时会被忽略。
What is more, nuget.org ignores authors
element as well :更重要的是, nuget.org 也忽略了
authors
元素:
Although each NuGet package's.nuspec file defines the package's authors, the nuget.org gallery does not use that metadata to define ownership .
尽管每个 NuGet 包的.nuspec 文件都定义了包的作者,但 nuget.org 库不使用该元数据来定义所有权。 Instead, nuget.org assigns initial ownership to the person who publishes the package.
相反,nuget.org 将初始所有权分配给发布 package 的人。 This is either the logged-in user who uploaded the package through the nuget.org UI, or the users whose API key was used with
nuget SetApiKey
ornuget push
.This is either the logged-in user who uploaded the package through the nuget.org UI, or the users whose API key was used with
nuget SetApiKey
ornuget push
.
I also checked the source code of PackTask
and although it gets the value of NuspecProperties
MSBuild property but it is used only if NuspecFile
MSBuild property is also set.我还检查了
PackTask
的源代码,虽然它获取了NuspecProperties
MSBuild 属性的值,但只有在设置了NuspecFile
MSBuild 属性时才使用它。 But in this case all package properties will be read from the specified .nuspec
file and the related MSBuild properties will be ignored.但在这种情况下,将从指定的
.nuspec
文件中读取所有 package 属性,并且将忽略相关的 MSBuild 属性。
So it seems that currently there is no way to force putting an owners
element into the dynamically generated .nuspec
file automatically.因此,目前似乎没有办法强制将
owners
元素自动放入动态生成的.nuspec
文件中。
What can be done?可以做什么?
.nuspec
file from the generated .nupkg
file..nupkg
.nuspec
。.nuspec
file as needed..nuspec
文件。.nuspec
file in the .nupkg
file with the updated one..nuspec
文件中的.nupkg
文件替换为更新后的文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.