1

I have a C# solution with single project (Project.csproj) which has 3 different build configurations each having different build directive (v1, v2, v3). The code inside the library changes depending upon these directives so you get 3 different DLLs after building. The reason for this is that this library is a wrapper for a 3rd party program DLL written in C. This program has 3 versions with some differences.

The question is, how do I create a Nuget package for this? Should I create 3 different packages or is it possible to create just one (then the depending project would just use some directive to pick the right one)? Do I have to use a specifically tailored nuspec file or is to possible to simplify this with "nuget pack Project1.csproj ... some params" (so that i don't have to fill in the version, dependencies, etc. manually)?

Thank you

Andrej Kmetík
  • 158
  • 3
  • 10

1 Answers1

1

You can only execute different code when the underlying framework would be different.But i don't suppose this is the case.

If i where you, i would create 3 nuget package templates and automate the process for building and releasing so you don't have to do all the work.

You will however need to create the nuget package once.

On automating the packages, you can see a howto here:

Since you have 3 different builds, you can call the "nuget package creation" seperately and adjust the requirements accordingly.

Conclusion: i would go with 3 packages that get build on release. The version is defined in your assembly version. You could call Powershell code to adjust this in your nuget spec (eg. always the right version code when publishing, ..)

If you are testing the package, release the package with a -beta tag. So nuget will know it's a prerelease version.

Community
  • 1
  • 1
NicoJuicy
  • 3,435
  • 4
  • 40
  • 66
  • 1
    Thanks for your answer. I used this (https://github.com/bspell1/NuBuild) solution from the link you posted and created 3 nuspec files in my solution. All packages are created automatically whenever I build my solution. – Andrej Kmetík Nov 27 '15 at 16:52