C
C#•3w ago
Diia Blood

I just want to wrap my head around dotnet

Hi there, nooby here. .NET, dotnet, ASP, CLR, it's all so utterly confusing. I am a person who only gets something once I have a lifecycle-like simulation of it in my head. I want to know what my C# project contains, what it does, and what it uses and goes through to get to the final executable file. I really wanna get into this language, but every. damn. time. I even get close to it. I am bombarded with obfuscated toolchains behind walls of folders and names I can't begin to remember. This is so much more painful than compiling C++ with MingW: C++ Source -> Mingw GCC.exe -> Compiled Binary Object -> Linker -> Compiled Executable. I get the jest of it, as I'm aware it's not perfect, but it's there! My biggest pain point with C# is the obfuscation of its compiler, interpreter, and its strong association with the devil device named "NuGet" . I just don't get it. I tried searching for some tutorial that doesn't yank "Download Visual Studio and press these buttons to make a project," at me, but I got nothing. The reliance on hidden toolchains and Visual Studio have been nothing but cancer to the way I learn things. If you got some article, video, or something that DEFINES the clear life cycle of a common C# project with relying on Visual Studio shortcuts, then please, forward them here.
196 Replies
ero
ero•3w ago
c# as a managed language is simply not as straightforward as an unmanaged language like c or c++. c# source code is compiled to IL, byte code that basically lowers your code to an already slightly optimized version. at runtime, this is then executed and further optimized by the just-in-time compiler, which makes changes to the assembly in tiers, depending on how important it believes these optimizations are (how often is this code run, for example). very simplified and I'm sure others will elaborate in terms of building stuff without vs, that's entirely possible. the dotnet cli is fairly powerful and can do most of what you need to create, compile, and execute your c# project. simple commands like dotnet new console and dotnet run will be enough to create and run a Hello World app debugging, of course, won't be possible without a proper ide
Diia Blood
Diia BloodOP•3w ago
I have some knowledge which does include the above, but what really burns me for no reason is the weird obfuscation of everything. A very basic example is in the way dotnet makes a project from a template. Where is this template stored originally? It's clearly downloading something when I ask it to make something new, where is it downloading? Why is not even telling me that it's downloading anything? Maybe this sounds like silly whining, but for some reason, this ticks me off to levels beyond what I can describe
ero
ero•3w ago
It's absolutely not downloading anything. These templates are stored (somewhere) in the dotnet install directory
Diia Blood
Diia BloodOP•3w ago
Nope, I tested with mstest-playwright and its internet usage spiked up Not a single line was written about these hundrads of megabytes are be thrown to, and not a single line to tell me, the end user, that this thing is clearly downloading something
ero
ero•3w ago
If anything, that's telemetry. The dotnet cli doesn't need an internet connection
Diia Blood
Diia BloodOP•3w ago
Then It might not be the template, but maybe some package that it requires?
ero
ero•3w ago
I'm telling you, all of this is installed on your machine NuGet doesn't really play a part in compiling or interpreting NuGet is a package manager where people host their libraries for others to consume. Fetching a package does require an internet connection for obvious reasons. Once downloaded, the library is available to you, you can reference it in your code, and will be copied to the output directory once you compile your project
Diia Blood
Diia BloodOP•3w ago
That is what I assumed at first, then I tried to compile something, then it complained about The "ResolvePackageAssets" task failed unexpectedly. with many references to NuGet, then later, the error disappeared for no reason. I mean, cool it works, but nothing passed through my head where which I understood anything. All I got is: NuGet error? Let me try to fix it. Oh, it got fixed before I had time to think about it and figure out the reason behind it. And obviously, this or that aren't my main gripes, it's the combination of all of them
ero
ero•3w ago
The dotnet ecosystem is pretty large and pretty old. Issues that are undocumented or unexplainable are bound to happen, just like in any other language The resolving of packages happens during project evaluation, done by MSBuild and the dotnet sdk There are a lot of parts to it If you'd like a more detailed look into how msbuild evaluates projects and runs the necessary targets and tasks, you can run dotnet build with the --bl flag, which will generate a binlog. You can view this binlog with the msbuild structured log viewer Just a heads up, it's very complicated And not usually something you need to or should care about I get wanting to understand how the sausage is made, but this one might not be worth the effort
Diia Blood
Diia BloodOP•3w ago
Yeah, it's a bit of painful reality
ero
ero•3w ago
It requires incredibly deep knowledge of all of these systems
Diia Blood
Diia BloodOP•3w ago
I can definitely see a programming ecosystem where which this is unnecessary, but it ain't got the same demand as this cursed language
ero
ero•3w ago
That's a you opinion :p
Diia Blood
Diia BloodOP•3w ago
That's true
ero
ero•3w ago
I find everything that has to do with .net very impressive
kumja1
kumja1•3w ago
Honestly I feel that c# is more straightforward than most languages I have used, though It can be hard to use if your not experienced with similar languages
Diia Blood
Diia BloodOP•3w ago
That's in relation to the syntax or the toolchain?
kumja1
kumja1•3w ago
Both
Diia Blood
Diia BloodOP•3w ago
I am not expert, but having 10+ dotnet-named folders in the entirety of my system is not what I would call a "straightforward toolchain", at least, with my definition
Cerberus1746 (Ping for Answers)
better than a hundred cmake files
Diia Blood
Diia BloodOP•3w ago
At least, they're in the same folder
Cerberus1746 (Ping for Answers)
that makes things worse
Diia Blood
Diia BloodOP•3w ago
Though, I don't want to defend Cmake that hard 😂
ero
ero•3w ago
I'm not sure where you see 10+ dotnet-named folders
Diia Blood
Diia BloodOP•3w ago
No description
ero
ero•3w ago
Plus, if I may, you can compile c, c++, and zig with sorbet ;) dotnet even
Cerberus1746 (Ping for Answers)
What is sorbet
ero
ero•3w ago
dotnet
Diia Blood
Diia BloodOP•3w ago
An icercream apparently
No description
ero
ero•3w ago
:resisting:
Cerberus1746 (Ping for Answers)
Kind of ice cream Your instructions were not clear my man
ero
ero•3w ago
Might be good to know where these are actually placed. Do you have multiple versions of the SDK and/or runtime installed? I corrected myself, idk what more you wany
Diia Blood
Diia BloodOP•3w ago
I am aware that the functionality of any dotnet-named folder will differ and you can guess that simply by the path, but my point was about how this toolchain is just structured in a way that is not meant to be... touched? messed with? something like that.
kumja1
kumja1•3w ago
Normally it will not appear like that
Diia Blood
Diia BloodOP•3w ago
But again, that's not how my brain functions 😭
ero
ero•3w ago
I don't know what toolchain should ever be touched That just seems like asking for trouble The sdk is installed in places that you shouldn't manually edit for a reason
Diia Blood
Diia BloodOP•3w ago
What I mean is meddled with in a way to understand how it works well enough to fix a decent amount of problems that would aries from you not having understood how it works
Cerberus1746 (Ping for Answers)
Is this sorbet we are talking about? https://sorbet.org/
ero
ero•3w ago
It was a misspelling of dotnet,can we please move on?
Cerberus1746 (Ping for Answers)
I actually legit thought it was a name of something, my bad
Diia Blood
Diia BloodOP•3w ago
I feel like I'm either the only person who feels this way towards C# specifically, or I'm just in a very small minority because I see no one complaining about the same points I normally complain about
ero
ero•3w ago
There's simply too much to understand, it's unreasonable for anyone to want to dive into the SDK to try and actually understand its inner workings Yeah no I've never seen anyone be this concerned with how it works
Cerberus1746 (Ping for Answers)
My thoughts are. If it works, I don't need to worry about it
Diia Blood
Diia BloodOP•3w ago
😭
ero
ero•3w ago
Besides the people working on it of course :p
Diia Blood
Diia BloodOP•3w ago
In think if I have to be more and more specific, it's the fact that dotnet is scattered all over the system rather than in a single folder I've worked with single-folder languages before, and regardless of how much it obfuscate, I don't have much problems with it
ero
ero•3w ago
It's simply impossible (simply from a logistical standpoint) to clutter everything into one place
Diia Blood
Diia BloodOP•3w ago
C# is the subject here or any toolchain?
ero
ero•3w ago
Like I said, it would be important to know the actual directory paths of those dotnet folders
Cerberus1746 (Ping for Answers)
oh man, let me tell you all about windows software, if you think they are only installed in a single place, you are very mistaken. And in fact, linux software too
Diia Blood
Diia BloodOP•3w ago
Well, I don't need to know what my browser does and what folder it's in, but I need to know that for a toolchain
Cerberus1746 (Ping for Answers)
hmmm, no you don't
Diia Blood
Diia BloodOP•3w ago
Also, I have a good idea of the general folders a program installs itself on in windows
Cerberus1746 (Ping for Answers)
you run dotnet build, it works
Diia Blood
Diia BloodOP•3w ago
I'm aware, I'm not saying this from a literal standpoint, but an anecdotal one
Cerberus1746 (Ping for Answers)
As an anedoctal standpoint, I run dotnet build, it builds
Diia Blood
Diia BloodOP•3w ago
Fair enough 😂 , I know I'm alone with this one
ero
ero•3w ago
If you're still concerned about the scatteredness, please genuinely share the paths. Otherwise, if you really care about the build process, do what I said with the binlog
Cerberus1746 (Ping for Answers)
I had to look up what anedoctal meant
Diia Blood
Diia BloodOP•3w ago
Here's the full list
No description
Diia Blood
Diia BloodOP•3w ago
To be clear, there were more, but I hated them and deleted them (they were in the programfiles(x86) folder so I assumed it's needed when I make a 32bit application)
ero
ero•3w ago
Well I mean most of them are analyzers No, you shouldn't have x86 versions of the sdk installed Unless you're on a x86 machine
Diia Blood
Diia BloodOP•3w ago
It was just lying there
ero
ero•3w ago
Which you're not
Diia Blood
Diia BloodOP•3w ago
So, from my point of view, they are all children of the main dotnet folder found in programfiles That is the main one
ero
ero•3w ago
Mhm
Diia Blood
Diia BloodOP•3w ago
dotnet.exe is where the compiler and other parts of the toolchain gets called But not the compiler itself? Where is roslyn
ero
ero•3w ago
I forgor
Cerberus1746 (Ping for Answers)
Don't look at me, I don't use windows
Diia Blood
Diia BloodOP•3w ago
lmao
ero
ero•3w ago
I don't know if it's still csc.exe?
Cerberus1746 (Ping for Answers)
Should be
Diia Blood
Diia BloodOP•3w ago
No description
Diia Blood
Diia BloodOP•3w ago
One in build tools (visual studio) and three more in whatever the heck that folder is None of which are in the dotnet folder
Cerberus1746 (Ping for Answers)
Visual studio have the fabulous tendency of installing multiple versions of everything
Diia Blood
Diia BloodOP•3w ago
For refernece I have that thing UNINSTALLED I have no clue why this is here
ero
ero•3w ago
Windows comes with .net framework
Cerberus1746 (Ping for Answers)
Seemingly your actual problem is Visual Studio and not dotnet/c#
Diia Blood
Diia BloodOP•3w ago
The bane of my existance 😭
Cerberus1746 (Ping for Answers)
and yes, windows comes with it
Diia Blood
Diia BloodOP•3w ago
here's the entire list
No description
Cerberus1746 (Ping for Answers)
just like linux, most of them, comes with python
ero
ero•3w ago
I don't think it's csc.ece anymore chief
Diia Blood
Diia BloodOP•3w ago
Ahahaha I will do a simply test
Cerberus1746 (Ping for Answers)
Oh, you have Unity too
Diia Blood
Diia BloodOP•3w ago
I will delete all of these and see if the c# project continues to compile
ero
ero•3w ago
Yeah nuke your system!
kumja1
kumja1•3w ago
If you struggle with that try jetbrains rider
Cerberus1746 (Ping for Answers)
careful, you might break your system, somehow
ero
ero•3w ago
Who just deletes random files that they don't know if they're important lol
Diia Blood
Diia BloodOP•3w ago
I do that
ero
ero•3w ago
Find an uninstaller, run that Use geek
Diia Blood
Diia BloodOP•3w ago
Also, all the files seem to be used by a program? Can't delete them
Cerberus1746 (Ping for Answers)
Why don't you just use gentoo
Diia Blood
Diia BloodOP•3w ago
gentoo?
ero
ero•3w ago
Linux users suck, do you see me going around telling people to use Windows
Diia Blood
Diia BloodOP•3w ago
I forgot rider does C#
Cerberus1746 (Ping for Answers)
Linux distribution where you can literally removes slices of the software trough the build system and package manager you won't need to delete anything because you choose what to install to begin with
Diia Blood
Diia BloodOP•3w ago
That would be rad But linux is not rad unfortunately no offense
Cerberus1746 (Ping for Answers)
none taken, just mentioned because thought you would actually love it
Diia Blood
Diia BloodOP•3w ago
gentoo Will keep it in mind
Diia Blood
Diia BloodOP•3w ago
ah
No description
Diia Blood
Diia BloodOP•3w ago
so it is nowhere near the dotnet folder thanks microsoft
ero
ero•3w ago
I don't think that's right @333fred? What's the compiler's executable and its path?
Cerberus1746 (Ping for Answers)
Seems like that one is the one that comes with windows
ero
ero•3w ago
:waiting: It's the one that comes with framework
Diia Blood
Diia BloodOP•3w ago
Alright
333fred
333fred•3w ago
No. Bad. Do not use
ero
ero•3w ago
(oh you'll love hearing about .net versioning)
333fred
333fred•3w ago
You don't care about where csc.exe is. All you care about is dotnet.exe
ero
ero•3w ago
So it is just that
Diia Blood
Diia BloodOP•3w ago
So it is the compiler?
333fred
333fred•3w ago
It runs the compiler for you. A hello world has 150+ arguments to csc.exe Don't concern yourself with it
Diia Blood
Diia BloodOP•3w ago
...
ero
ero•3w ago
lmfaooo
Diia Blood
Diia BloodOP•3w ago
Fair enough
333fred
333fred•3w ago
I get wanting to understand all the pieces in play
ero
ero•3w ago
See that's the thing. The whole system is so massively complex, it's futile to want to try understanding it all in its entirety
Diia Blood
Diia BloodOP•3w ago
Okay, not understand, what about know where it is I give up understanding
ero
ero•3w ago
Well what's "it"?
333fred
333fred•3w ago
The abstraction that should really matter to you is that dotnet.exe (or just dotnet on non-windows) wires up all the calls and arguments to csc.exe (or just csc), by transforming data from your .csproj files
ero
ero•3w ago
But first, we need to talk about msbuild.exe
Diia Blood
Diia BloodOP•3w ago
Compiler, interpreter, standard assembly references, etc Alright, at least that shifts my focus to the .csproj file Oh yeah
kumja1
kumja1•3w ago
It's like the cmake equiv for c#
ero
ero•3w ago
That's selling it short by light-years
kumja1
kumja1•3w ago
simplest explanation though
ero
ero•3w ago
I suppose
333fred
333fred•3w ago
It's a good description
Diia Blood
Diia BloodOP•3w ago
I see no references to my .cs project files so I'm definitely unsure of how it works Fair enough
333fred
333fred•3w ago
Nowadays, the .csproj does a few things for you
Cerberus1746 (Ping for Answers)
sconsfile then?
ero
ero•3w ago
Again, binlog :p
333fred
333fred•3w ago
You used to have to list all your .cs files, but that's painful There's an implicit include for **/*.cs
Diia Blood
Diia BloodOP•3w ago
I will check it out actually I'm interested, but what did you say were the tool needed to view these files?
333fred
333fred•3w ago
Filtering out the default bin and obj intermediate artifact directories https://msbuildlog.com/
Diia Blood
Diia BloodOP•3w ago
All .cs files in the folder hierarchy?
333fred
333fred•3w ago
Kirill has an avalonia version that runs on Linux as well, but you'll have to build from source for it Yep, from the csproj root down
Diia Blood
Diia BloodOP•3w ago
goit it
Diia Blood
Diia BloodOP•3w ago
Now, this mess
No description
Cerberus1746 (Ping for Answers)
It's a glob, ** means recusively all folders down
ero
ero•3w ago
Oh god the intermediate output :ICANT:
Diia Blood
Diia BloodOP•3w ago
I assume obj is similar to C++ making object binaries out of files before combining into an .exe and bin is just that .exe with the needed libraries
333fred
333fred•3w ago
Yes, though obj has a bit more than that After a dotnet restore, nuget will have written out all your package information, that's those json files
Cerberus1746 (Ping for Answers)
Do you check those stuff even when doing stuf in C/C++?
Diia Blood
Diia BloodOP•3w ago
Check?
ero
ero•3w ago
Or maybe rather, did you when you first started I guess Yeah like did you care about the toolchains this much? Where the compiler lives and what it does? Whether it produces intermediate output?
Diia Blood
Diia BloodOP•3w ago
Yes. Only after I got that piece of information was I comfortable writing more C++ code
ero
ero•3w ago
Horribly inefficient I feel like
333fred
333fred•3w ago
Eh, some people learn best top-down, some people learn best bottom-up
Diia Blood
Diia BloodOP•3w ago
It literally did nothing to my efficiency but it made my brain very happy Bro is outing me in public 😭
333fred
333fred•3w ago
I would definitely suggest that you try and ignore anything but the high-level details for things in obj though. I work on the compiler, and I can't say that, other than package.assets.json, I've ever needed to look at anything in obj It's all a more verbose and direct consequence of things in your project file
ero
ero•3w ago
I will say working with the compiler sdk, with msbuild, knowing the cli and sdk a bit better definitely gave me a lot more appreciation for the systems at play and the people behind it
Diia Blood
Diia BloodOP•3w ago
Reading this hurts so badly... But I can't but agree Okay, how about this, is it possible to learn enough so one can be in no need to rely on visual studio? in any way shape or form
333fred
333fred•3w ago
Absolutely
ero
ero•3w ago
Fred and I both don't use vs :3
Diia Blood
Diia BloodOP•3w ago
As long as I get out of that hellhole, I can probably* manage You guys are Linux, no?
333fred
333fred•3w ago
Correct
ero
ero•3w ago
I'm on Windows
Diia Blood
Diia BloodOP•3w ago
Oh, but no vs alright
ero
ero•3w ago
(I use tiny11 btw)
Cerberus1746 (Ping for Answers)
i just use visual studio code and have dotnet installed trough my package manager
333fred
333fred•3w ago
The only times I need to open VS are when I need to do VB work that I can't just get done in a few lines
ero
ero•3w ago
Yup, vscode for us as well I do most of my stuff via the cli
Diia Blood
Diia BloodOP•3w ago
Alright, going making this thread definitely gave me more confidence to deal with this language more. At least, I don't' have the same bitter pain as when I opened it. I will see what I can do for the time being to learn more C#, which brings me to another pain point. What's a good way to go forward without long tutorials or big files downloaded?
ero
ero•3w ago
It's just quicker
Cerberus1746 (Ping for Answers)
Just one thing If you are going to use Unity, you are never touching dotnet yourself
Diia Blood
Diia BloodOP•3w ago
I plan to do more than Unity
ero
ero•3w ago
Well, to learn the language, I say just use it Think of something to do and do jt
Cerberus1746 (Ping for Answers)
pretty much
Diia Blood
Diia BloodOP•3w ago
Alright, visual novel it is
ero
ero•3w ago
You can write a visual novel in Avalonia!
Diia Blood
Diia BloodOP•3w ago
Oh? Looks pretty good
ero
ero•3w ago
But if you really wanna learn unity, do that :p
kumja1
kumja1•3w ago
Take a look at others code and try and understand it
ero
ero•3w ago
I just think desktop dev is useful. Especially Avalonia can teach a lot of techniques
Diia Blood
Diia BloodOP•3w ago
No, no, I really do wanna do more manual stuff as those things can easily transferred into any language + the benefit of learning a high-in-demand language such as C# more closely. Also that, yeah
ero
ero•3w ago
Maybe Avalonia isn't so good if you wanna do manual stuff. The appeal there is that the patterns you use allow you to simplify a lot of things away Dependency injection, source generation xaml interpretation
Diia Blood
Diia BloodOP•3w ago
But it seems like a good starting point
ero
ero•3w ago
Maybe a console app is better
Diia Blood
Diia BloodOP•3w ago
Oh yeah, that's what I think of before a visual novel. The VN is more of a big goal with smaller, ladder-like goals behind it
ero
ero•3w ago
Like a hangman game or tic tac toe or connect 4 or chess or poker Or a text adventure!
Diia Blood
Diia BloodOP•3w ago
that also works! Anyhow, I took enough of you guys' time already Thanks a bunch for the help
ero
ero•3w ago
It is 3am!
Diia Blood
Diia BloodOP•3w ago
It's 4:40 here! A.M.
Cerberus1746 (Ping for Answers)
it's 10 pm
kumja1
kumja1•3w ago
You also practice of hackerrank and solve different problems 8:44pm for me
ero
ero•3w ago
Meh, some people will agree, some will vehemently disagree
kumja1
kumja1•3w ago
I understand but honestly it's a lot easier than coming up with problems for yourself, and I only use it when I dont have a project idea
ero
ero•3w ago
Things like leetcode are good to challenge you mentally and think about problem solving But you won't gain actual coding skill
Cerberus1746 (Ping for Answers)
try to make a game engine, not as hard as you think if you a use a bunch of libraries, the fewest libraries you use, the exponentially harder it gets tho it's fun
ero
ero•3w ago
Okay I mean that's a bit much But after some time it's a viable choice Very very different problems to solve there as well
Diia Blood
Diia BloodOP•3w ago
that would be the dream
ero
ero•3w ago
Graphics, performance, ui/ux, physics I think even just a library that solves a problem you haven't found someone else implement a solution for and putting that up on nuget is huge
Cerberus1746 (Ping for Answers)
that's why I said that it is not as hard if you use a bunch of libraries
ero
ero•3w ago
Doesn't have to be fancy, just has to be useful

Did you find this page helpful?