I have created a nuspec file for my solution. The solution has a few empty folders.
I have downloaded the latest nuget.exe from https://docs.nuget.org/consume/command-line-reference
However when I run my nuget pack command the empty folders are not being included. Looking at the documentation for the pack command, I am interpreting the fact that empty folders are included by default because of this flag:
ExcludeEmptyDirectories: Prevent inclusion of empty directories when building the package.
Unfortunately I am not able to get the pack command to include my empty folders.
My files structure is similar to Root
- Folder1
- Folder2
- Folder3
Folder1 and Folder2 have content files within them, but Folder3 is empty
My nuspec file defined as follows:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Package_7.2_140526</id>
<version>7.2.140526</version>
<title>Package 7.2 rev 140526</title>
<authors>My Company</authors>
<owners>My Company</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A vanilla website</description>
</metadata>
</package>
I have not included individual files because I want the nuget pack to include everything. While my example is only of 3 folders there are significantly more than than.
This is the nuget command I am running from the command line
nuget pack "c:\Projects\Package 7.2 rev 140526\Packagee 7.2 140526.nuspec" -OutputDirectory c:\Projects -NoPackageAnalysis
When that did not work I tried with the -ExcludeEmptyDirectories flag just incase
nuget pack "c:\Projects\Package 7.2 rev 140526\Packagee 7.2 140526.nuspec" -OutputDirectory c:\Projects -NoPackageAnalysis -ExcludeEmptyDirectories
But it still will not include the empty folder.
What needs to be done to get the nuget pack command to include the empty folders?
Update
I used the Nuget Package Explorer to add the empty folders to the solution and then looked in the modified nuspec file. It appears that the only way to include empty folders within nuget is to have a file entry as
<file src="folder3\_._" target="folder3\_._" />
And then have a postdeploy.ps1 file to delete all the files named "_._"
So it appears that will always have to specify the files.
Ps. I tested it with the following structure \Folder3\Folder4.
If folder4 is empty then folder3 and folder4 are not created unless you include the "_._" file
But if there is a way to include empty folders without having to resort to _._ file then want to know, especially if the blank folder is nested as it is easy to get excluded