❔ 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
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.
naot doesn't xcompile though
iif
iirc
xcompile?
4) Okay, so, do you know what it defaults to? Since otherwise the default is AnyCPU, AFAIK.
it doesnt default to anything, you have to specify the arch
and the os too actually
crosscompile
oh
yeah thats what i said
yeah it doesn't do it iirc
to be sure what do you mean by cross compile?
NAOT cannot compile a binary for one OS from another OS
oh
idk about that
why wouldnt it tho
you have to set up a GNU clang or GCC toolchain for it
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?
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
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?yeah publishaot is only about publishing
I'd have to use a CLI to compile it to native codedepends on the IDE, but I always recommend using CLI when possible
which componenton 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
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...you probably only need msvc
I'll try different configurations tomorrow, see how it goes.
In the meanwhile, still looking for answers for questions 1-3. 😄
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 thingsWell, yes, but, what's inside that variable?
the preprocessor symbols
More specifically?
the #define and #if things
whatever custom symbols have been defined so far
The ones that have been defined in code?
So if I remove that, I can no longer define preprocessor symbols in code?
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
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?msbuild might source these in some other way.
that variable is supposed to be custom symbols, msbuild doesn't pollute that
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.