Sdk: It is not possible to pack multiple projects into one NuGet package

Created on 29 May 2017  路  6Comments  路  Source: dotnet/sdk

Steps to reproduce

Using VS 2017 and new .csproj format

  1. Create CommonLib.csproj project, it should not be published as NuGet package.
  2. Create ProjectA.csproj project, it should be published as NuGet package.
  3. Add project reference from ProjectA to CommonLib.
  4. Pack the ProjectA (with Visual Studio or CLI).

Expected behavior

ProjectA.nupkg is created. It contains ProjectA.dll and CommonLib.dll.

Actual behavior

ProjectA.nupkg is created. It contains only ProjectA.dll. CommonLib is added as a NuGet dependency.

Additional info

I have tried to add <IsPackable>false</IsPackable> property to the CommonLib.csproj, but it is not take into the consideration.

Environment data

dotnet --info output:
NET Command Line Tools (1.0.1)

Product Information:
Version: 1.0.1
Commit SHA-1 hash: 005db40cd1

Runtime Environment:
OS Name: Windows
OS Version: 6.1.7601
OS Platform: Windows
RID: win7-x64
Base Path: C:Program Filesdotnetsdk1.0.1

Most helpful comment

@Patrickkk, although the issue is closed, I wanted to provide an example scenario when multiple projects are needed.
We use C# and F# together in a single solution, half of the projects are written in each language.

All 6 comments

While it would probably be nice to have (especially for legacy stuff).
Isn't it a bit strange that there are 2 projects when it is distributed as 1 package? Unless there are some external factors into play forcing you to separate shouldn't it simply be 1 project since it is distributed as 1 package?

Yes, that is definitely possible to just merge the two projects together, and this is a workaround that I will use.

But I would imagine, that there might be some valid scenarios similar to this one:

CommonLib.csproj <- this provide no value on its own, so it should not be published.
ProjectA.csproj <- Published as NuGet. Refers CommonLib, so it would need to contain it as part of the package.
ProjectB.csproj <- Published as NuGet. Refers CommonLib, so it would need to contain it as part of the packages.

This issue was moved to NuGet/Home#5360

@Patrickkk, although the issue is closed, I wanted to provide an example scenario when multiple projects are needed.
We use C# and F# together in a single solution, half of the projects are written in each language.

@auduchinok The issue wasn't closed to indicate that it shouldn't be fixed or that there aren't scenarios for it. It was moved to the appropriate repository at NuGet/Home#5360, which in turn was closed as a duplicate of NuGet/Home#3891. I suggest that you follow up on NuGet/Home#3891, which is still open.

@nguerrera, thank you, I've already checked these issues. My response wasn't about the issue itself, it was a reaction to the @Patrickkk's response which I found worth answering.

Was this page helpful?
0 / 5 - 0 ratings