簡體   English   中英

為什么 contentFiles 文件夾中的文件沒有被復制到 bin 文件夾中?

[英]Why are the files from the contentFiles folder not getting copied over to the bin folder?

我正在嘗試將我的 sql 文件從 nuget 包中獲取到我的應用程序的 bin 文件夾中。 我正在為它設置 .nuspec 文件。 我可以在 .nuget 文件夾中看到 sql 文件是 nuget 包的一部分,但它們沒有反映在 bin/Debug 文件夾中。

<?xml version="1.0" encoding="utf-8"?>
<package >
  <metadata>
    <id>$id$</id>
    <version>$version$</version>
    <title>$title$</title>
    <authors>Athi</authors>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>$description$</description>
    <copyright>$copyright$</copyright>
    <tags>Logger</tags>
    <dependencies>
        <dependency id="Dapper" version="2.0.123" />
        <dependency id="System.Data.SqlClient" version="4.8.3" />
    </dependencies>
      <contentFiles>
          <files include="bin\Release\net6.0\Scripts\*.sql" buildAction="Content" copyToOutput="true" />
      </contentFiles>
  </metadata>
  <files>
      <file src="bin\Release\net6.0\Scripts\*.*" target="lib\net6.0\Scripts" />
      <file src="bin\Release\net6.0\Scripts\*.*" target="contentFiles\Scripts" />
  </files>
</package>

首先,根據文檔

包項目應使用以下模式構建內容:

/contentFiles/{codeLanguage}/{TxM}/{any?}

例如:

Language- and framework-agnostic:
    /contentFiles/any/any/config.xml

net45 content for all languages
    /contentFiles/any/net45/config.xml

C#-specific content for net45 and up
    /contentFiles/cs/net45/sample.cs

您似乎沒有將它們放入 NuGet 包中的正確目錄。

其次,根據文檔contentFiles僅在NuGet 4.0+ with PackageReference受支持。 您是否使用了足夠高的 NuGet 版本? 您是否在項目文件中使用PackageReference而不是項目中的packages.config文件?

提示:如果您發現文檔中缺少您嘗試做的示例,請從https://nuget.org下載一些(最近制作的)真實包,以找到與您想要的類似的包並使用NuGet 包Explorer以查看包的排列方式。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM