2017-08-10 104 views
0

我已经列入我nuspec文件中的以下内容:nuspec contentFiles元素的元数据无效

<?xml version="1.0"?> 
<package> 
    <metadata minClientVersion="3.3"> 
     <contentFiles> 
      <file src="*.css" target="_css" /> 
     </contentFiles> 
    </metadata> 
</package> 

不过,我得到以下错误:

MSBUILD : OctoPack error OCTONUGET: The element 'metadata' in namespace ' http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd ' has invalid child element 'contentFiles' in namespace ' http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd '. List of possible elements expected: 'language, licenseUrl, projectUrl, requireLicenseAcceptance, summary, tags, frameworkAssemblies, title, references, copyright, authors, description, version, iconUrl, owners, dependencies, id, developmentDependency, releaseNotes' in namespace ' http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd '.

当我看这里:https://blog.nuget.org/20160126/nuget-contentFiles-demystified.html,我已经完成似乎是正确的。我错过了什么?

回答

1

NuSpec file reference表示<Contentfile><File>是两个独立的标签。你不能<Contentfile>

下窝<file>使用以下模式:

<files> 
    <file src="bin\Debug\*.dll" target="lib" /> 
    <file src="bin\Debug\*.pdb" target="lib" /> 
    <file src="tools\**\*.*" exclude="**\*.log" /> 
</files> 

<contentfiles>仅支持的NuGet 3.3+,也许你有一个旧的NuGet(2.X的NuGet或更早版本)?

0

这有两个问题。

一个是根据其他答案。

第二个目标并没有与

lib, content, build, or tools

开始按文档。

我最终的标记是这样的:

<?xml version="1.0"?> 
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> 
    <metadata minClientVersion="3.3"> 
     <id>Application Id</id> 
     <version>$version$</version> 
     <description>Solution description</description> 
     <authors>Development Team</authors> 
    </metadata> 
    <files> 
     <file src="\_css\**\*.*" target="content\_css" /> 
     <file src="\_scripts\**\*.*" target="content\_scripts" /> 
     <file src="\_images\**\*.*" target="content\_images" /> 
    </files> 
</package> 

我然后创建在IIS虚拟目录的“内容”目录,使文件的引用并没有需要改变。