Search code examples
nugetnuget-package

csproj equivalent to nuspec target attribute


NuGet nuspec files allow you to specify the target for <file> elements.

eg.

<files>
  <file src="things/**/*" target="content/stuff/" />
</files>

Is there an equivalent if you're using a csproj (and dotnet pack), instead of a .nuspec file?

eg. Given

<ItemGroup>
  <Content Include="things/**/*" />
</ItemGroup>

Can I add something to that to make those files end up in content/stuff in the .nupkg file?


Solution

  • According to the Microsoft docs, I'd say it should look like this:

    <Content Include="things/**/*">
      <Pack>true</Pack>
      <PackagePath>content/stuff/</PackagePath>
    </Content>