I have a C# Class Library (CL) that I need to package into a nuget package. This project targets .Net Standard 2.0 and has a .csproj file that looks like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<Version>1.0.13</Version>
<PackageTags>custom task</PackageTags>
<PackageIconUrl></PackageIconUrl>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2.0|AnyCPU'">
<DocumentationFile>C:\xxx\xxx\xxx.xml</xxx>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.0|AnyCPU'">
<DocumentationFile>xxx.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Content Include="TaskMetadata.json">
<PackagePath>TaskMetadata.json</PackagePath>
<Pack>True</Pack>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.DataAnnotations" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.1" />
</ItemGroup>
</Project>
Now the challenge is creating the package and these are the methods I have tried.
In VS, right click the project and pick publish. This creates a nuget package that does not include any of the third party dependencies such as Newtonsoft.json, SqlClient etc.
nuget pack xxx.csproj -IncludeReferencedProjects
This results inError NU5012: Unable to find 'bin\Debug\xxx\bin\Debug\'. Make sure the project has been built.
nuget pack xxx.csproj -c Release
This results inFile 'C:\projects\xxx\xxx\Release' does not exist.
4 Unpacking the nuget package from try 1 and extracting the xxx.nuspec file and then running nuget pack xxx.nuspec
but this seem to package eveything in the entire folder.
How can I package my library in a nuget version containing only release compiled code and third party dependencies? I would prefer to not having to sync both a .csproj file and .nuspec file all the time to make this work.