Problem: I have .sql files in my Visual Studio project which I want to exclude from my NuGet package. These .sql files are nested into various directories, and I have been unable to successfully exclude all .sql files from my nuget package.
1: I've created a .nuspec file by running the following command on my target project:
nuget spec
2: I've edited the resulting nuspec file so that it looks like this:
<?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Security Core Impl</description>
<releaseNotes>Security Core Impl</releaseNotes>
<copyright>Copyright 2013</copyright>
<tags>Security Core</tags>
</metadata>
<files>
<file src="**\*.dll" target="lib\net40\" exclude="**\*.sql;" />
</files>
</package>
3: I run the following command to build my .nupkg:
nuget pack -Prop Configuration=Release
Whenever I install this package into another project, however, the .sql files get included. I've tried a few different variations of the exclude above, and have tried the -Exclude switch. Nothing seems to work.
All .sql files are marked:
I have also tried clearing my NuGet cache via Visual Studio options.
Note: The NuGet package is hosted on a private server.
I've just been having the exact same issue, but with .txt files. The solution as pointed out by a colleague is to change the Build Action from "Content" to "None".
I'm assuming your *.sql files are under the content
folder of the package?
<file src="**\*.dll" target="lib\net40\" exclude="**\*.sql;" />
tells NuGet to add all .DLL files under lib\net40. SQL files are ignored as your include didn't include them anyway.
Can you try adding <file target="content\" exclude="**\*.sql;" />
to the nuspec?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With