繁体   English   中英

使用project.json在nuget包中包含内容文件

[英]Include content files in nuget package using project.json

我正在使用此.nuspec文件生成nuget包。

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
    <id>ClassLibrary1</id>
    <version>1.0.0</version>
    <title>Title</title>
    <authors>Author</authors>
    <owners>Owner</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Description</description>
    <copyright>Copyright 2017</copyright>
    <contentFiles>
      <files include="any/any/myfile.xml" buildAction="None" copyToOutput="true" flatten="true" />
    </contentFiles>
  </metadata>
</package>

在构建引用此nuget包的项目时使用此配置,内容文件将被复制到输出文件夹。 现在我将我的项目转换为.Net核心项目,我想使用project.json生成nuget包并删除.nuspec文件。 这是我的project.json

{
  "version": "1.0.0-*",
  "dependencies": { },
  "frameworks": {
    "net452": {
    }
  },
  "packOptions": {
    "files": {
      "mappings": {
        "contentFiles/any/any/myfile.xml":  "Configuration/myfile.xml"
      }
    }
  },

  "scripts": {
    "postcompile": [
      "dotnet pack --no-build --configuration %compile:Configuration%"
    ]
  }
}

现在的问题是,当构建一个引用这个nuget包的项目时,它也会尝试编译内容文件。 构建失败了。 如何从编译中排除contentFile?

由于脚本和转换的类似原因,目前对内容的支持已被禁用,但我们正在设计对内容的支持。

这来自官方的nuget文档页面。 你可以在这里找到这些信息。

您无法在ASP.NET核心包中添加内容。 您可以使用bower / npm包来代替使用内容。

暂无
暂无

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

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