为什么来自ContentFiles文件夹的文件未被复制到BIN文件夹?

发布于 2025-01-31 04:04:20 字数 1191 浏览 4 评论 0原文

我正在尝试将我的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>

I'm trying to get my sql files from the nuget package to the bin folder of my Application. I was setting up the .nuspec file for it. I can see in the .nuget folder that the sql files are a part of the nuget package but they are not reflected in the bin/Debug folder.

<?xml version="1.0" encoding="utf-8"?>
<package >
  <metadata>
    <id>$id
lt;/id>
    <version>$version
lt;/version>
    <title>$title
lt;/title>
    <authors>Athi</authors>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>$description
lt;/description>
    <copyright>$copyright
lt;/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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

荆棘i 2025-02-07 04:04:20

首先,根据 docs

包装项目应使用以下模式构建内容:

/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+上支持Packagereference。您是否正在使用足够高的Nuget版本?您是否在项目文件中使用packagereference,而不是项目中的packages.config文件?

提示:如果您发现文档中缺少您尝试做的事情的示例,请从 https://nuget.org 找到一个类似于您想要的事情并使用 nuget package Explorer 查看包裹的排列方式。

Firstly, according to the docs:

The package project should structure content using the following pattern:

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

For example:

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

It doesn't look like you are putting them into the correct directory in your NuGet package.

Secondly, according to the docs, contentFiles is only supported on NuGet 4.0+ with PackageReference. Are you using a high enough version of NuGet? Are you using PackageReference in your project files instead of a packages.config file in your project?

TIP: If you find the documentation is lacking in examples of what you are attempting to do, download some (recently made) real packages from https://nuget.org to locate one that does something similar to what you want and use NuGet Package Explorer to see how the packages are arranged.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文