12
votes

We are experimenting with nuget for our visual studio projects. However, we only (or at least mainly) use nuget for our own external references, and we store them in a local repository (network share). What I would like to know is how to handle the whole debug/release situation.

Concrete (simplified) situation:

We have a main project that has references to two shared components that we developed ourselves. These shared components are also used in other products of our company

When we build the main project (azure pipelines), we build the debug and release versions of the project. However, we can only specify a single nuget package for each external reference.

What we want to accomplish to to use the debug version of the shared components during the debug build, and the release version during the release build. However, these are (as far as I know) actually different packages.

What is the way of tackeling this issue? Is there, for instance, a way to include both the release and debug versions in a single nuget package? Is it possible to have to different nuget configurations for different build configuration settings?

I've found Best practices with Nuget: Debug or Release?, however this topic doesn't really address my issue. This thread is more a discussion about whether to publish debug or release versions to a remote server. We want to publish both and use both in a private repository. We have no intention of sharing our libraries with the rest of the world.

1

1 Answers

3
votes

A NuGet package will normally hold just a single set of assemblies for a particular target framework. It is not really designed to ship a debug and release version since you are publishing the NuGet package to be consumed by other users. Normally you do not publish a debug and a separate release version of your application to end users.

You may be able to workaround this by using a custom MSBuild .targets file in the NuGet package that has its own references and configuration information. You can use this .targets file as an extension to your project. It will be imported so you can define the references as you need based on the configurations defined in your project. It is not ideal but it should work.