TeamCity Professional 9.1.7 (build 37573)
Nuget.exe 3.4.3 (default in Teamcity)
We are using Nuget.exe(instead of Octopack) to pack our output build artifacts to be published onto TC nuget feed and then consumed by Octopus for deployments. We don’t need the lib and content folders as explained on Octopus documentation:
Tip: Structure the package as you want it extracted on disk. NuGet was designed for packaging libraries to be used in Visual Studio, which is a different usage scenario than that of deploying applications. When creating a library NuGet package, for example, NuGet encourages you to put binaries in a lib folder, and content files in the content folder. But for Octopus Deploy, this convention doesn’t make sense - your ASP.NET application will expect binaries to be in a bin folder for example. Instead, just ignore the NuGet package structure conventions, and simply structure your package exactly like you want it to appear when extracted on disk.
We are using Teamcity’s ‘Nuget Pack’ runner and passing the .csproj files to the pack command. We also have a custom nuspec file to pack artifacts into bin folder and the web.config to the root of the nuget package (to reiterate, we invoke nuget pack on .csproj instead of .nuspec)
<?xml version="1.0"?> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <metadata> <version>$version$</version> <authors>Removed</authors> <owners>Removed</owners> <id>Removed</id> <title>Removed</title> <requireLicenseAcceptance>Removed</requireLicenseAcceptance> <description>Removed</description> <copyright>Removed</copyright> <dependencies> <dependency id="AutoMapper" version="4.2.1" /> <dependency id="CommonServiceLocator" version="1.3" /> </dependencies> </metadata> <files> <file src="bin\*.dll" target="bin\" /> <file src="bin\*.pdb" target="bin\" /> <file src="Enterprise\Schemas\*.*" target="Enterprise\Schemas\" /> <file src="Web.config" target="Web.config" /> <file src="Web.DevTest.config" target="Web.DevTest.config" /> <file src="Web.SysTest.config" target="Web.SysTest.config" /> <file src="Web.PreProd.config" target="Web.PreProd.config" /> <file src="Web.Prod.config" target="Web.Prod.config" /> </files> </package>
Now, the output nuget package contains bin folder and the .config files in the root as expected, but it also contains bin and lib folders.
I can’t seem to find an option to get this of these folders in the output package. These folders are redundant for us and make no difference to the final deployment, but we don’t need them there. We can of course delete them using a script pot-deployment, but surely there would be an option to exclude them at the nuget pack stage itself.