C
C#2y ago
Torn

❔ Compilation option questions

I am currently reading through different options that can be set inside a .csproj file, as well as overall compilation options, and some of those are confusing to me. 1) For DefineConstants, what does the $(DefineConstants) string mean? 2) What is the difference between a Platform and a PlatformTarget? 3) What is a Win32Manifest, and why would I want to include / not include it (e.g. with the NoWin32Manifest option)? For AoT compilation specifically: 4) Is targetting AnyCPU instead of x64 possible? What would this even do? 5) How do I compile for Linux?
29 Replies
sibber
sibber2y ago
4) no. aot compiles ahead of time to a specific cpu arch 5) https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/
Native AOT deployment overview - .NET
Learn what native AOT deployments are and why you should consider using it as part of the publishing your app with .NET 7 and later.
WhiteBlackGoose
naot doesn't xcompile though iif iirc
sibber
sibber2y ago
xcompile?
Torn
TornOP2y ago
4) Okay, so, do you know what it defaults to? Since otherwise the default is AnyCPU, AFAIK.
sibber
sibber2y ago
it doesnt default to anything, you have to specify the arch and the os too actually
WhiteBlackGoose
crosscompile
sibber
sibber2y ago
oh yeah thats what i said
WhiteBlackGoose
yeah it doesn't do it iirc
sibber
sibber2y ago
to be sure what do you mean by cross compile?
WhiteBlackGoose
NAOT cannot compile a binary for one OS from another OS
sibber
sibber2y ago
oh idk about that why wouldnt it tho
WhiteBlackGoose
you have to set up a GNU clang or GCC toolchain for it
Torn
TornOP2y ago
Damn, I can't compile from Windows to Linux? So I'm gonna need to get something that runs Linux and install the compiler there?
WhiteBlackGoose
yeah, but it shouldn't be hard GNU comes with GCC so install basic debian probably < 1 G and you're set if you need arm, you need to get a few packages, though note that I'm talking about NAOT which cyberrex mentioned it's not the same for AOT such as R2R
Torn
TornOP2y ago
Yes You know, I should have maybe tried to actually compile the thing before asking. I can't seem to manage that at all... Even with the PublishAot property, it will simply do the usual compilation if I run it? I'd have to use a CLI to compile it to native code? Not a particular problem (although everything else neatly has an UI button), but then I also need to have C++ installed? Which component(s) specifically?
WhiteBlackGoose
yeah publishaot is only about publishing
I'd have to use a CLI to compile it to native code
depends on the IDE, but I always recommend using CLI when possible
which component
on GNU, it's out of the box on Windows, try to publish it if it fails bc you don't have things installed, you will need to install smh like Visual C++ in VS Installer
Torn
TornOP2y ago
Yeah... Platform linker not found ... Make sure to install the Desktop Development for C++ workload. But that thing has a bunch of optional components, making the whole thing range from 200MB to over 10GB...
sibber
sibber2y ago
you probably only need msvc
Torn
TornOP2y ago
I'll try different configurations tomorrow, see how it goes. In the meanwhile, still looking for answers for questions 1-3. 😄
Anton
Anton2y ago
the dollar expands that variable can be used to do a += for strings so a = a + ";text" would be <a>$(a);text</a> 2 and 3 would be some niche things
Torn
TornOP2y ago
Well, yes, but, what's inside that variable?
Anton
Anton2y ago
the preprocessor symbols
Torn
TornOP2y ago
More specifically?
Anton
Anton2y ago
the #define and #if things whatever custom symbols have been defined so far
Torn
TornOP2y ago
The ones that have been defined in code? So if I remove that, I can no longer define preprocessor symbols in code?
Anton
Anton2y ago
what no it's just the symbols defined by the build if you set it to PROD for example, then PROD will be defined in your source files so you could do #if PROD just read on how preprocessor symbols work if you don't know that
Torn
TornOP2y ago
No, see, if I remove that variable, it still says I have defined stuff like NET7.0, and DEBUG or whatever the name for the profile I'm compiling is, but what else does it add?
Anton
Anton2y ago
msbuild might source these in some other way. that variable is supposed to be custom symbols, msbuild doesn't pollute that
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server