I'm having trouble with NuGet copying files to output, using NuGet v4 CLI.
My directory structure looks like this:
reporepo\CodeAnalyzer.nuspecrepo\CodeAnalyzer.propsrepo\contentFiles\any\any\StyleCop.ruleset
Here's my CodeAnalyzer.props file:
<?xml version="1.0" encoding="utf-8"?><Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup><PackageName>CodeAnalyzer</PackageName><PackageVersion>0.1.0</PackageVersion></PropertyGroup><PropertyGroup><CodeAnalysisRuleSet>StyleCop.ruleset</CodeAnalysisRuleSet></PropertyGroup></Project>
And CodeAnalyzer.nuspec file:
<?xml version="1.0"?><package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"><metadata><id>CodeAnalyzer</id><description>Provides standard code analyzer tooling and customisation.</description><authors>Me</authors><version>0.1.0</version><dependencies><dependency id="StyleCop.Analyzers" version="1.1.118" /></dependencies><contentFiles><files include="any/any/*" buildAction="Content" copyToOutput="true" flatten="false" /></contentFiles></metadata><files><file src="contentFiles\any\any\StyleCop.ruleset" target="contentFiles" /><file src="CodeAnalyzer.props" target="build" /></files></package>
On CLI I am packing using:
.\nuget.exe pack .\CodeAnalyzer.nuspec
In the resulting .nupkg, there is a contentFiles directory with the StyleCop.ruleset file in, so that works.
If I then install the package in a project, it picks up on the StyleCop.Analyzers dependency fine, and it looks for the StyleCop.ruleset file, so the .props file is fine.
But the StyleCop.ruleset file isn't placed anywhere.
Feel like I've tried a lot of changing buildActions to None/Content, copyToOutput to true/false, different paths for the contentFiles.file element and the file.file element.
Edit: the consuming project is using PackageReferences for NuGet packages, not packages.config.