How does NuGet contentFiles work?

adrianm

I'm trying to create a nuget package with content which work with different kinds of projects.

TestSource.nuspec look like this:
<contentFiles> <files include="cs\any\TestSource.cs" buildAction="Compile" /> </contentFiles> </metadata> <files> <file src="TestFolder\TestSource.cs" target="content/TestFolder" /> </files> (the file is available both as contentFiles\cs\any\TestSource.cs and TestFolder\TestSource.cs)

The created package works fine in a "normal" project but nothing happens in a packagereference project.

I assume I'm missing something simple

adrianm

Found this out myself.

You need to add the file twice in the files section

  <contentFiles>
    <files include="cs\any\TestSource.cs" buildAction="Compile" />
  </contentFiles>
</metadata>
<files> 
  <file src="TestFolder\TestSource.cs" target="content/TestFolder" />
  <file src="TestFolder\TestSource.cs" target="contentFiles/cs/any" />
</files>

The package will then work for both normal and packagereference projects.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related