cake-build / cake-build/cake

Support creating NuGet packages using both .csproj info and NuGetPackSettings info

Open
#1,037 14 comments 0 reactions 0 assignees View on GitHub
Waiting for issuer feedback
Dominant language
C#
Stars
4.2k
Forks
778
Avg merge
3h 37m
Merged PRs (30d)
21

Description

### What You Are Seeing?

Using the `NuGetPack(FilePath filePath, NuGetPackSettings settings)` command where filePath is pointed at a `.csproj` file, you can create a NuGet package with the dependencies defined based on the .csproj file references. However, the NuGetPackSettings (i.e. the `settings` parameter) are only partially used. A .nuspec file is not created and the settings are only used to determine command line parameters. Settings like the `Files` property are ignored.

Using the `NuGetPack(NuGetPackSettings settings)` command, you can create a NuGet package that uses your `NuGetPackSettings` definition (from the `settings` parameter). This allows you to specify additional files to include (e.g. symbols). However, the .csproj references are not used and must be defined in the `NuGetPackSettings`.

We use Proget which allows a regular nuget package to contain both the assemblies and symbols (i.e. you do not need a separate nuget package for symbols).

Given the current behavior above, we can create a NuGet package that has dependencies automatically defined or a NuGet package that contains symbols, but not a package that has both.
### What is Expected?

The `NuGetPack` method should allow the user to specify if the `NuGetPackSettings` should be used to generate `.nuspec` file in the same folder as the project file (i.e. if the filePath points to a project file, a .nuspec file will be automatically created in the project file's folder). The `nuget pack` command will still be passed the .csproj file as its file parameter, but the NuGet tool will then detect that the .nuspec file exists and use both .csproj/.nuspec information (refer to https://docs.nuget.org/create/creating-and-publishing-a-package in the "From a project" section).

It appears that the Cake repo already has the majority of the required code. I would propose that a new setting is added to the `NuGetPackSettings` class (e.g. `bool CreateNuspecFileForProject`).
If true and the filePath is pointed to a .csproj, the `NuGetPackSettings` would be used to create/update the .nuspec file in the project's folder prior to execute the `Run` method (in the `NuGetPacker` class).
### What version of Cake are you using?

0.13.0
### Are you running on a 32 or 64 bit system?

64-bit
### What environment are you running on? Windows? Linux? Mac?

Linux, Windows
### Are you running on a CI Server? If so, which one?

Jenkins, Teamcity
### How Did You Get This To Happen? (Steps to Reproduce)

Contributor guide

Open the contributing guide

Research direction

Start by inspecting NuGetPackSettings and the NuGetPacker Run flow, including the existing code related to .nuspec generation. Trace how a .csproj path and settings are currently handled, then verify the combined behavior for dependencies and additional Files. Done means the opt-in behavior creates or updates the .nuspec beside the project and the resulting package includes both sources of information.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system, release
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.