Nuget Pack conditional compilation symbol
Asked Answered
E

0

6

I would like to be able to package my nuget files with a conditional compilation symbol (NUGET or similar) so that I can use a preprocessor directive specifically for my nuget build.

eg

#if NUGET 
    [Obsolete("use v2.IMyContract", true)]
#endif

Is there some way I can pass this into the nuget pack MyProject.csproj command?

Why

I have an assembly which contains contracts for a plugin, there are multiple versions of these contracts (.vX. namespaces within the assembly) which need to be built and referenced by the actual implementation for backwards compatibility.

I would like to be able to distribute these contracts with a breaking [Obsolete(true)] attribute to force consumers to use the latest version of the contracts when they upgrade their nuget package. However internally I still need to use these objects to maintain my backwards compatibility.

Equestrian answered 23/1, 2014 at 2:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.