Home: The -IncludeReferencedProjects does not work in Nuget Version 4.1.0.2450

Created on 8 Aug 2017  路  17Comments  路  Source: NuGet/Home

Details about Problem

The -IncludeReferencedProjects command doesn't work - it does not add the dependent DLLs into the nuget package. The detailed output lists the referenced projects under "dependencies" but doesn't pack them into the package. Any help or guidance is appreciated.

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe):

NuGet version (4.1.0.2450):

dotnet.exe --version (1.0.4):

VS version (15.2):

OS version (Win 10 V1703, Build 12063.483):

Worked before? If so, with which NuGet version:
Hasn't worked before

Detailed repro steps so we can see the same problem

  1. Execute "nuget pack .\SDKs\FileSystem\FileSystemSDK\FileSystemSDK.csproj -IncludeReferencedProjects"
  2. Observe package (by renaming .nupkg to .zip), the dependent dlls from referenced projects are not included.

Other suggested things

Verbose Logs

PM> nuget pack .\SDKs\FileSystem\FileSystemSDK\FileSystemSDK.csproj -IncludeReferencedProjects -Verbosity detailed
NuGet Version: 4.1.0.2450
Attempting to build package from 'FileSystemSDK.csproj'.
MSBuild auto-detection: using msbuild version '15.1.1012.6693' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
Packing files from 'C:\HSAClients\\SDKs\FileSystem\FileSystemSDK\bin\Debug'.
Add file 'C:\HSAClients\\SDKs\FileSystem\FileSystemSDK\bin\Debug\FileSystemSDK.dll' to package as 'lib\dotnet5.0\FileSystemSDK.dll'
WARNING: Description was not specified. Using 'Description'.

Id: FileSystemSDK
Version: 1.0.0.0
Authors:
Description: Description
Dependencies: Microsoft.NETCore [5.0.0, ), Microsoft.NETCore.Portable.Compatibility [1.0.0, ), Newtonsoft.Json [9.0.1, ), NuGet.Build [2.12.0, ), NuGet.CommandLine [4.1.0, ), <Referenced Project #1> [1.0.0, ), [1.0.0, )

Added file '[Content_Types].xml'.
Added file '_rels/.rels'.
Added file 'FileSystemSDK.nuspec'.
Added file 'lib/dotnet5.0/FileSystemSDK.dll'.
Added file 'package/services/metadata/core-properties/26725b99ca7d4d6a9c49eea446210529.psmdcp'.

Successfully created package 'C:\HSAClients\\FileSystemSDK.1.0.0.nupkg'.
PM>

Sample Project

Very helpful if you can zip a project and paste into this issue!

Upon request, it is a straightforward issue, hopefully you can do this yourself because I can't put my project in here.

Pack ByDesign Bug

Most helpful comment

As you can see in the original post, nuget is creating the package from the csproj file which is the recommended approach for this version of nuget, and isn't related to project.json or packages.config per the reason you closed this post.

Can you relate the reason for the original post to the reason you decided to close this defect?

"Attempting to build package from 'FileSystemSDK.csproj'."

All 17 comments

//cc
Any ideas @rohit21agrawal

@thejeff77
From https://docs.microsoft.com/en-us/nuget/tools/nuget-exe-cli-reference#pack

Indicates that the built package should include referenced projects either as dependencies or as part of the package. If a referenced project has a corresponding .nuspec file that has the same name as the project, then that referenced project is added as a dependency. Otherwise, the referenced project is added as part of the package.

Does your dependent project have a nuspec file that has the same name as the project?

Thanks!

No. Since I'm building with Nuget 4, I'm making the assumption that building with .csproj files is the recommended approach. I'm also witnessing that the referenced project is in fact not being added as part of the package. Thanks for any additional help or fixes.

@thejeff77 is this a NETCore project that you are trying to pack?

Not entirely sure, but I can check tomorrow. Does that change things?

yes. NuGet.exe doesn't really have support for packing NETCore projects. you should use dotnet.exe pack or msbuild /t:pack to pack a NETCore project.

Also, for NETCore projects, any referenced projects are added as a package reference by design. We are, however, considering working on implementing support for adding referenced project's dll into the parent nupkg.

Hmm, I'll give some of those a try. I'll try to add more context tomorrow for what I was trying to do, and let you know if its a NETCore project.

PLEASE do that! If the nuget pack command could somehow put all of the files that end up in bin/ into the package automatically that would be awesome. I think that is what this command is supposed to do... It has a sort of recursive nature to it..

I'm currently experiencing the same problem with a _regular_ NET.4.5.2 project. So it appears this problem is NOT NETCore related. Any progress on this issue would be much appreciated.

@basbossinkdivverence could you please attach a repro project for us to investigate?

An example reproduction can be found here.

Bump. Any update on this?

I don't know if your question is directed to me but I've posted a link to a repository that reproduces this problem quite some time ago. The reproduction repository can be found here: https://github.com/basbossinkdivverence/nuget-5720-repro .

@basbossinkdivverence this is because you have a project.json in your project. the presence of project.json/nuspec is seen as an indication that the project will be packed and shipepd as a nupkg.

The -IncludeReferencedProject flag only really makes sense when your project is managing dependencies via packages.config file.

Also note that project.json is now deprecated and i strongly urge you to make a move to PackageReference based csproj files.

As you can see in the original post, nuget is creating the package from the csproj file which is the recommended approach for this version of nuget, and isn't related to project.json or packages.config per the reason you closed this post.

Can you relate the reason for the original post to the reason you decided to close this defect?

"Attempting to build package from 'FileSystemSDK.csproj'."

So if we go the advocated route of PackageRef, we sacrifice automated package reference chaining? If so, that's a load of crap!

Still waiting on this one. @rohit21agrawal you closed this as works as expected saying
"i strongly urge you to make a move to PackageReference based csproj files".
Of course thats exactly what the OP said he was doing
Execute "nuget pack .\SDKs\FileSystem\FileSystemSDK\FileSystemSDK.csproj -IncludeReferencedProjects"

Looks like there are multiple reports. Guess this should have been closed as duplicate versus Works as expected.
Duplicate of 4054#

Was this page helpful?
0 / 5 - 0 ratings