✅ dotnet build and preprocessor symbol definition
Hi, anyone knows how to define a preprocessor symbol when running dotnet build? I want to define a symbol for linux, i tried these things i found online: /p:LINUX=true, -p:LINUX=true, /p:LINUX but it seems to just ignore it and compile as if it wasn't defined
13 Replies
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
The reason why i needed a preprocessor symbol is because i have a function that needs to call unmanaged code and it depends on the os, i got what i wanted by adding $(OS) to the conditional compilation symbols list and then defining that in the cli, works as intended
Thanks for the help
Btw the reason why i have to do this is beacause the calls i have to do are really os dependant functions, if windows i need to call timeBeginPeriod and if linux i just have to use usleep, there's no "clean" workaround for that afaik
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Yeah, if that's the intended way
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Yeah that's what i did, i found it online
Also
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
The reason why i named it "OS" instead of "ExtraProps" or something like that is because it gives an error if the value contains a ;
And tbh i didn't bother to figure out why
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Meaning i can only set it to one value, not several like LINUX;RELEASE etc
I'm fine with any of these 2 solutions tho
The first one looks like the intended way but you end up having to check on runtime
The second one is fully at compile time but a bit more hacky
The extra property is the solution to the original question so this is solved
Tysm
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Use the /close command to mark a forum thread as answered
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View