为什么来自ContentFiles文件夹的文件未被复制到BIN文件夹?
我正在尝试将我的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>$idlt;/id>
<version>$versionlt;/version>
<title>$titlelt;/title>
<authors>Athi</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$descriptionlt;/description>
<copyright>$copyrightlt;/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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,根据 docs
看起来您似乎并没有将它们放入Nuget软件包中的正确目录中。
其次,根据文档,
contentfiles
仅在nuget 4.0+上支持Packagereference
。您是否正在使用足够高的Nuget版本?您是否在项目文件中使用packagereference
,而不是项目中的packages.config
文件?Firstly, according to the docs:
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 onNuGet 4.0+ with PackageReference
. Are you using a high enough version of NuGet? Are you usingPackageReference
in your project files instead of apackages.config
file in your project?