1
votes

I have a C# class library targeting .NET 4.7.2 for which I use VSTS to build and deploy to a private NuGet package feed whenever I push a commit. This all works fine.

I also have a legacy project targeting .NET 4.0 in which I would like to make use of the above library. I have created a new branch of my library and ported it to target .NET 4.0 (had to remove some unsupported functionality) and have created a new VSTS CI build that is triggered by pushes on this branch. Again, all working fine.

The issue is that the resulting NuGet package just shows up as a new version of the .NET 4.7.2 one! Ideally I would like to have 2 packages show up in my private feed: MyPackage and MyPackage.dotnet40

Is this even possible? Or should I be doing something completely different?

Solved

Thanks to @DanielMann's answer below I solved this problem by adding a .nuspec file to my project and re-configuring (slightly) my NuGet pack task in my VSTS build definition:

  1. navigate to project root (not solution) in command prompt
  2. run nuget spec to create a .nuspec file alongside your .csproj file (might need to add nuget.exe to your PATH)
  3. fill out the .nuspec file. I replaced all the placeholders except $version$ which VSTS automatically replaces, but you can provide values for all the placeholders in the Nuget pack task under Advanced>Additional build properties. The important one is the $id$ placeholder, change this to whatever you want your package to be called
  4. add the .nuspec to source control and commit/push
  5. update the NuGet pack task so that it points to your new .nuspec file rather than your .csproj file
2

2 Answers

1
votes

If your project that's being packaged has a .nuspec file, change the package name in the NuSpec file.

If it's based off of the project name, change the project name.

Basically, there's no problem here -- you forked the codebase, so you have two totally separate entities that you can do whatever you want with.

0
votes

You have to create a separate feed and target your new project.