昨天,NuGet 3.3发布了(发布说明),并且有一个新的contentFiles元素支持(文档)。然而,我似乎无法做到这一点。
我使用NuGet.exe作为构建过程。现更新为第3.3节。我还将Visual更新到2015年更新1并重新启动。
这是我的nuspec文件(Hello.world.nuspec):
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata minClientVersion="3.3">
<id>Hello.world</id>
<version>1.0.0</version>
<title>Greeting library</title>
<authors>Timothy Klenke</authors>
<description>Greetings for the world</description>
</metadata>
<contentFiles>
<files include="*" />
</contentFiles>
</package>我使用以下命令行运行:
nuget.exe update -Self
nuget.exe pack Hello.world.nuspec我得到了以下信息:
MSBuild自动检测:从'C:\Program (x86)\ msbuild \14.0\bin‘使用MSBuild '14.0’。试图从'Hello.world.nuspec‘构建包。命名空间'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd‘中的元素'package’在名称空间'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd‘中具有无效的子元素'contentFiles’。可能需要的元素列表:名称空间“http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd”中的“文件”。
我认为我正在运行所有应该支持新的contentFiles XML元素的最新版本,但是工具似乎并不了解它。我遗漏了什么?我知道包含属性的文件是垃圾文件,但是有人使用新的contentFiles元素有完整的nuspec文件吗?
发布于 2015-12-02 12:40:22
元素<contentFiles>必须在<metadata>中,根据NuSpec参考。所以应该是这样的:
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata minClientVersion="3.3">
<id>Hello.world</id>
<version>1.0.0</version>
<title>Greeting library</title>
<authors>Timothy Klenke</authors>
<description>Greetings for the world</description>
<contentFiles>
<files include="*" />
</contentFiles>
</metadata>
</package>发布于 2018-06-27 14:37:06
@蒂莫西
你是对的。它是一个组合,具有元数据/contentFiles元素以及文件元素中的定义。我有一个C#测试实用程序库,当使用PackageReference引用它时,它需要将PowerShell文件包含在项目输出/bin文件夹中。我将为您提供下面的XML。我想你可以从中得到你需要的东西。
特别注意:确保您的语言和框架值处于正确的路径(即您的语言和框架值将类似cs/ get 45/YourFile.cs)。我使用任何/any/myFile.psm1,因为我希望将该文件视为语言无关和平台无关。如果没有,我会在构建时得到代码分析错误。
此外,将文件放置在“contentFiles”目录中也很重要。
( .nuspec参考文档中定义的语言和框架选项) https://learn.microsoft.com/en-us/nuget/reference/nuspec#including-content-files
<package>
<metadata>
<id>SomeLibrary</id>
<version>$version$</version>
<title>SomeLibrary</title>
<authors>Somebody</authors>
<owners>Somebody</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Some library that does things I enjoy.</description>
<releaseNotes />
<copyright>Copyright 2017</copyright>
<tags>PowerShell Testing</tags>
<contentFiles>
<files include="any/any/SomePS.psd1" buildAction="none" copyToOutput="true" />
<files include="any/any/SomePS.psm1" buildAction="none" copyToOutput="true" />
</contentFiles>
</metadata>
<files>
<file src="*.dll" target="lib\net461" />
<file src="*.pdb" target="lib\net461" />
<file src="SomePS.psd1" target="contentFiles\any\any" />
<file src="SomePS.psm1" target="contentFiles\any\any" />
</files>
</package>发布于 2020-03-06 02:41:36
节点中的"/“问题。如果使用:
<files include="any/any/x.dll" buildAction="None" copyToOutput="true" flatten="true" />它必须是:
<files include="any\any\x.dll" buildAction="None" copyToOutput="true" flatten="true" />但是它不适用于.NET框架?!
https://stackoverflow.com/questions/34031650
复制相似问题