Search code examples
c#nuget.net-standard-2.0

.Net Standard project with nugets build target


I am using:

dotnet pack MyProject.csproj

for creating nuget netstandard/net462 packages and it works fine for simple use cases.

How do I configure MyProject.csproj to include files in the "build" nuget level? Or can I add reference to nuspec file from .csproj ?

This is how it would be in .nuspec file:

<package>
    <files>
        <file src="Libs\*.*" target="build" />
    </files>
</package>

Solution

  • There is a tag in csproj that points to the nuspec file to be used instead of the csproj:

      <NuspecFile>MyLibrary.nuspec</NuspecFile>
      <NuspecProperties>version=$(Version);id=$(AssemblyName)</NuspecProperties>