C
C#6mo ago
Prozaks

✅ 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
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Prozaks
Prozaks6mo ago
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
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Prozaks
Prozaks6mo ago
Yeah, if that's the intended way
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Prozaks
Prozaks6mo ago
Yeah that's what i did, i found it online Also
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Prozaks
Prozaks6mo ago
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
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Prozaks
Prozaks6mo ago
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
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX6mo ago
Use the /close command to mark a forum thread as answered
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View