I need to build a condition where one package is only included on Windows and another package only on Linux. Nuget supports Condition
attributes to include a PackageReference
only in specific cases. That's exactly what I need, but the example only checks the framework version with the $(TargetFramework)
variable.
I need a variable like $(OS)
but I don't know which variables exists and what's their contect to write correct conditions. For MSBuild I found a list of well-known properties and build macros (but for C++). It seems that $(Platform)
is Win32
, however I have no clue what it looks on Linux: Is it Linux? The distribution? Linux32/64?
For Windows I tried
<PackageReference Include="IBM.Data.DB2.Core" Version="3.1.0.400" Condition="'$(Platform)' == 'Win32'"/>
which doesn't work, I assume that this is only applied to C++ code and not C#.
I'm wondering that there must be a documentation of those variables for .NET Core with the avaliable values, sadly I can't find one.
Background: DB2
My app needs the IBM.Data.DB2.Core*
package to access the database of a legacy application. The IBM.Data.DB2.Core package only works on Windows, where IBM.Data.DB2.Core-lnx works on Linux. If we use the win package on linux, it throws a Unable to load shared library 'db2app64.dll' error. Since this app should run on Win and Linux, I'd like to make it ready for both platforms.