C
C#3y ago
Lvgraef

✅ Is .net required

i want to create a C# project. ive coded in C# before, but that was thru unity.. so this is the first time setting up the project. i am also not rly sure what .net is even used for like what it does, i dont need any UI or anyhging
88 Replies
arion
arion3y ago
Do you prefer a visual approach or a command line approach to building code? Visual studio can set up a lot of the stuff for you (including the sdks)
Lvgraef
LvgraefOP3y ago
i dont mind cmd line i kinda want to use fleet cuz im testing that out at the same time
deathsangel1234
ASP.net is generally used for APIs. You don't need to use ASP.net at all, it's just a framework.
deathsangel1234
ASP.NET overview
Introduction to ASP.NET, a free framework for creating websites, web applications, and web APIs.
Thinker
Thinker3y ago
they didn't say ASP.NET .NET is the "framework" which C# runs on. Unless you're using Unity (which does its own weird stuff), the .NET SDK is what contains the compiler, build tools, etc., and you need it to do anything at all with C#.
Lvgraef
LvgraefOP3y ago
i just said .net in genreal i thought windows ahd a native compiler
Thinker
Thinker3y ago
Yes but that one's really old and outdated
arion
arion3y ago
allright, first step would be to grab yourself a download of the SDK https://dotnet.microsoft.com/en-us/download/dotnet (.NET 6.0 or 7.0, your choice, higher the number the more recent it is.) When you click on one you can grab the Installer for the platform ur on and which architecture (x64 / x86) .NET Frameworks doesnt use a command line interface as far as i know
Microsoft
.NET Downloads (Linux, macOS, and Windows)
Official .NET downloads for Linux, macOS, and Windows. .NET is a free, cross-platform, open-source developer platform for building many different types of applications.
Lvgraef
LvgraefOP3y ago
oh welli downloaded teh sdk
arion
arion3y ago
dotnet core does though ^^ dotnet
Lvgraef
LvgraefOP3y ago
wdym they dont use cmd line interfaace
Thinker
Thinker3y ago
If you're gonna use Visual Studio, the installer will install everything for you.
Lvgraef
LvgraefOP3y ago
then how do i use it nah i dont want visual studio also that doesnt work for me
Thinker
Thinker3y ago
Then you're gonna have to use the command line :/
Lvgraef
LvgraefOP3y ago
tried to use it before but it complains about azure and stuff
arion
arion3y ago
can you run dotnet --info and see what comes up?
Lvgraef
LvgraefOP3y ago
bwrong thing
Lvgraef
LvgraefOP3y ago
It was not possible to find any installed .NET Core SDKs Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from: https://aka.ms/dotnet-download
Microsoft
.NET Downloads (Linux, macOS, and Windows)
Official .NET downloads for Linux, macOS, and Windows. .NET is a free, cross-platform, open-source developer platform for building many different types of applications.
Lvgraef
LvgraefOP3y ago
but i havent unzipped it yet or anything
Thinker
Thinker3y ago
run dotnet --list-sdks
Lvgraef
LvgraefOP3y ago
nothing D:
Thinker
Thinker3y ago
Then you'll have to install the SDK
arion
arion3y ago
posted the link here where u can download them
Lvgraef
LvgraefOP3y ago
do i just run dotnet.exe
Thinker
Thinker3y ago
well you just did that
Lvgraef
LvgraefOP3y ago
fair then whats wrong where do i put the zip lol
Thinker
Thinker3y ago
I think you just unzip it and run the installer
Lvgraef
LvgraefOP3y ago
i would but i dont see any installer inside of it
Thinker
Thinker3y ago
Did you download the right thing?
arion
arion3y ago
i think they downloaded "Binaries"
Thinker
Thinker3y ago
ah
Lvgraef
LvgraefOP3y ago
did it no i dont think i did
Thinker
Thinker3y ago
Lvgraef
LvgraefOP3y ago
oh i did smh
Thinker
Thinker3y ago
then run the exe that that downloads
Lvgraef
LvgraefOP3y ago
i
Lvgraef
LvgraefOP3y ago
but oh diff thing
Thinker
Thinker3y ago
yes
Lvgraef
LvgraefOP3y ago
ok ye this looks better
arion
arion3y ago
NOOO
Lvgraef
LvgraefOP3y ago
i only do this once right its the same as with the java sdk?
arion
arion3y ago
well, there's the sdk, and then there's the runtime
Lvgraef
LvgraefOP3y ago
what java doesnt have that 0.o what do i do with th eruntime lol why do i need it
arion
arion3y ago
People need the runtime to "run" your program
Thinker
Thinker3y ago
basically The SDK installs everything, including the runtime yes it does
Lvgraef
LvgraefOP3y ago
uh wtf
Thinker
Thinker3y ago
it's probably just installed along with the JDK
Lvgraef
LvgraefOP3y ago
smh microsoft didnt expect anything less from them tbh
Thinker
Thinker3y ago
yeah you can disable that with an environment variable
Lvgraef
LvgraefOP3y ago
oh nice
arion
arion3y ago
You have the SDK, which contains the runtime too, but your users need the runtime to run it, not the sdk
Lvgraef
LvgraefOP3y ago
OH YE smh i forgot its the JRE of course wait users have to install stuff to run the application i create with this the whole reason i wanted to use C# was cuz its native so they dont have to do anything unlike with java
arion
arion3y ago
people have to install java too
Thinker
Thinker3y ago
well... yes... but that's an ancient version
Lvgraef
LvgraefOP3y ago
thats why i wanted to use C# and not java
Thinker
Thinker3y ago
However, you can publish native executables
Lvgraef
LvgraefOP3y ago
so it doesnt just build into .exe
arion
arion3y ago
this
Lvgraef
LvgraefOP3y ago
that you can just use on any windows divice you want? what
Thinker
Thinker3y ago
well not by default, but you can enable that
Lvgraef
LvgraefOP3y ago
wait what does it compile to by default
Thinker
Thinker3y ago
not really, again the only NET version that's included by default on Windows is absolutely ancient
Lvgraef
LvgraefOP3y ago
is a diff language better for what i want or should i still use C# ugh but i cant have the user install things
Thinker
Thinker3y ago
C# is a great language totally not biased Again you don't have to, you can publish native executables so users don't have to install anything
Lvgraef
LvgraefOP3y ago
0.o ok i thought this meant i couldnt
Thinker
Thinker3y ago
But it's a tradeoff - either you use a language like C++ or Rust and have to compile a separate version for each architecture, or you use a language like C# or Java which only require a runtime to be installed but is otherwise cross-platform There is no language which is 100% cross-platform and will work everywhere with no setup
Lvgraef
LvgraefOP3y ago
C# is cross platform?! oh i only need it for windows i didnt know C# was crossplatform lol cool
Thinker
Thinker3y ago
again, you need the runtime, but yes it's cross-platform That ancient version of C# I mentioned is not xplat and Windows-only, and also really old
arion
arion3y ago
normal build:
arion
arion3y ago
self-contained (no runtime needed, but is x86):
Lvgraef
LvgraefOP3y ago
oh
arion
arion3y ago
as u can see, a lot more files (and a lot more space it takes up dotnet build -f net7.0 dotnet publish -r win-x86 -f net7.0 --self-contained true But once you have access to the dotnet command, you can run dotnet new console to make a console project dotnet build to build it to an exe dotnet run to run it (basically)
Thinker
Thinker3y ago
yep all you have to do is
dotnet new console
dotnet run
dotnet new console
dotnet run
Lvgraef
LvgraefOP3y ago
okay but what will the users have to do i want to have a all in one file what language should i use then like rust or C++ right?
Thinker
Thinker3y ago
again, you can still use C#
Lvgraef
LvgraefOP3y ago
ok i dont undrstand anymore
Thinker
Thinker3y ago
Rust and C++ have to be published per architecture. C# and Java can either be published once as long as the user has the runtime installed or per architecture. Per architecture is a native executable which does not require a runtime.
Lvgraef
LvgraefOP3y ago
oh ye i want that
arion
arion3y ago
this
Lvgraef
LvgraefOP3y ago
oh ok i want it for x64
arion
arion3y ago
then do win-x64
Lvgraef
LvgraefOP3y ago
ok fair idk what the diff is but well i know what the diff is on a low level... but idk what the diff actually is
Thinker
Thinker3y ago
On the low level, win-x64 gets compiled to native machine code, while regular compiles to an intermediate cross-platform format called IL. The cross-platform format requires the runtime to run. But it doesn't need to be recompiled per platform.
Lvgraef
LvgraefOP3y ago
eh its only for windows so idc about the cross platform
Thinker
Thinker3y ago
If you were wanna publish something others can run, using an xplat language is really useful
Accord
Accord3y 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.

Did you find this page helpful?