簡體   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