I want to build a nuget
package for a design time only package. This package contains resources (a ruleset file, a build props file and an assembly) for using a custom code analysis rule set.
My nuspec file (inside my CodeAnalysis
assembly project) looks like this:
<package>
<metadata>
<id>$id$</id>
<version>$version$</version>
<authors>$author$</authors>
<description>$description$</description>
<references>
</references>
<developmentDependency>true</developmentDependency>
</metadata>
<files>
<!-- copy rules assembly to tools folder -->
<file src="bin\Release\CodeAnalysis.dll" target="tools\CodeAnalysis.dll" />
<file src="tools\CodeAnalysis.ruleset" target="tools\CodeAnalysis.ruleset" />
<file src="build\CodeAnalysis.props" target="build\CodeAnalysis.props" />
</files>
</package>
When in build this package, the CodeAnalysis.dll
assembly is present in \lib\net40\CodeAnalysis.dll
, and a copy is added in \tools\CodeAnalysis.dll
.
When i use this package in another project, the default behavior is that a reference to the assembly is added to the project. Since this a a design / build time only assembly (only used when executing code analysis on the project), i don't want nuget
to add this reference.
I've looked into the <references>
section of the nuspec
file, but that doesn't give me a clue how to prevent a reference from being made.
How do i build a nuspec file so that nuget does not add a project reference when installing the nuget package?
Pass the
-tool
command line switch to nuget. This will not include the DLL as a referenced assembly.