Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Empty Nuget package for just dependencies

Tags:

c#

nuget

I have a project I'd like to put all my dependencies into one nuget package. The idea is that when I need to I can just pull in that one nuget package instead of 10 that I require. Is this possible to do?

When I created a library I removed the class file and just pulled in the dependencies but could not get a package to create.

like image 867
TheDizzle Avatar asked Sep 18 '25 14:09

TheDizzle


1 Answers

You can do this by setting the IncludeBuildOutput property to false while creating the package.

For example [using VS 2017] -

  1. File > New Project > .NET Core class library
  2. Right click on project and edit csproj to have the following content -
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net46</TargetFramework>
    <PackageId>MetaPackage</PackageId>
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
    <IncludeBuildOutput>false</IncludeBuildOutput>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
    <PackageReference Include="NuGet.Versioning" Version="4.7.0-rtm.5104" />
    <PackageReference Include="NUnit" Version="3.10.1" />
  </ItemGroup>

</Project>
  1. Right click and build project
  2. Look at the package at <project_dir>\bin\Debug\MetaPackage.1.0.0.nupkg

This will create a package that has no \lib and the nuspec file should have package reference dependencies.

You can read more about IncludeBuildOutput here.

like image 62
Ankit Mishra Avatar answered Sep 20 '25 02:09

Ankit Mishra