I am trying to use a preprocessor directive in .Net core, but I can\'t determine the correct way to get the directive to be set:
static void Main(string[] ar
The thing you need to set is /p:DefineConstants=MAC
note this will override constants set in the project like DEBUG
or TRACE
that may be set so the full version you would likely use would be
for a debug build
dotnet msbuild /p:DefineConstants=TRACE;DEBUG;NETCOREAPP1_1;MAC /p:Configuration=Debug
and for a release build
dotnet msbuild /p:DefineConstants=TRACE;NETCOREAPP1_1;MAC /p:Configuration=Release
An easier solution would create a configuration called Mac
and in your csproj have
TRACE;NETCOREAPP1_1;MAC
Then from the command line you just need to do
dotnet msbuild /p:Configuration=Mac