7

I want to have a nuspec file that automatically reads all the info from packages.config and so on, building up all the dependencies, but also includes just one single additional file.

Is there a way to do this?

For example, here is a nuspec file that does almost what I want:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <metadata>
    <id>My.Project</id>
    <version>1.0.0.0</version>
    <owners>Me</owners>
    <authors>Me</authors>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <title>My.Project</title>
    <description>My.Project</description>
    <frameworkAssemblies />
    <copyright>Copyright ©  2015</copyright>
    <tags></tags>    
  </metadata>
</package>

If my project references ten nuget packages, the above nuspec file will detect that and add them as dependencies when I pack the package together.

But, the moment I add a files element then all the auto-linking to my other nuget dependencies stops:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <metadata>
    <id>My.Project</id>
    <version>1.0.0.0</version>
    <owners>Me</owners>
    <authors>Me</authors>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <title>My.Project</title>
    <description>My.Project</description>
    <frameworkAssemblies />
    <copyright>Copyright ©  2015</copyright>
    <tags></tags>    
  </metadata>
  <files>
    <file src="myfile.dll" target="lib\net45" />
  </files>
</package>

Without the auto-linking I effectively have to maintain two copies of all the dependencies for my project: one in the csproj file and one here.

There must be a way to do this?! I want to just add a single extra file to my package, via a nuspec.

joshcomley
  • 28,099
  • 24
  • 107
  • 147

2 Answers2

0

If you only need to include an additional file in a package packed from a project, simply add the file to the project and set its Build Action to Content. It will be added to the package under Content directory and on installing will be added to the consuming project.

Leon V
  • 541
  • 5
  • 12
0

Are you using Octopus Deploy?

If using Octopus Deploy this can be resolved by adding /p:OctoPackEnforceAddingFiles=true, which tells OctoPack to include the normal files on top of what's defined in <files>..</files>

Read this for more information

https://octopus.com/docs/packaging-applications/nuget-packages/using-octopack/octopack-to-include-buildevent-files

Frank Fu
  • 3,483
  • 2
  • 28
  • 38