Intro to C# and .NET - what the project structure looks like, how to build and run the project etc.
├── src
│ └── MyProject
└── test
src
will have all the source code for the project and test
will have unit testssrc
you can have multiple projects or components that make up a larger project.csproj
means it’s a C# project. It contains info about your projectProgram.cs
contains the starting code
dotnet run
picks up the .csproj
file in the folder by default├── src
│ └── MyProject
│ ├── bin
│ │ └── Debug
│ │ └── netcoreapp3.0
│ │ ├── MyProject
│ │ ├── MyProject.deps.json
│ │ ├── MyProject.dll
│ │ ├── MyProject.pdb
│ │ ├── MyProject.runtimeconfig.dev.json
│ │ └── MyProject.runtimeconfig.json
│ ├── MyProject.csproj
│ ├── obj
│ │ ├── Debug
│ │ │ └── netcoreapp3.0
│ │ │ ├── MyProject
│ │ │ ├── MyProject.AssemblyInfo.cs
│ │ │ ├── MyProject.AssemblyInfoInputs.cache
│ │ │ ├── MyProject.assets.cache
│ │ │ ├── MyProject.csprojAssemblyReference.cache
│ │ │ ├── MyProject.csproj.FileListAbsolute.txt
│ │ │ ├── MyProject.dll
│ │ │ └── MyProject.pdb
│ │ ├── MyProject.csproj.nuget.cache
│ │ ├── MyProject.csproj.nuget.dgspec.json
│ │ ├── MyProject.csproj.nuget.g.props
│ │ ├── MyProject.csproj.nuget.g.targets
│ │ └── project.assets.json
│ └── Program.cs
└── test
bin/
is where your build output (i.e. binaries, aka assembly) would goobj/
is a temp folder that is created during the restore/build process. You can delete this safely.gitignore
both bin/
and obj/
folders1bin/ # equivalent of public/
2obj/ # equivalent of node_modules/
1dotnet run # from within the directory that contains .csproj
2dotnet run --project src/GardeBook # give it a directory where .csproj is
dotnet run
= dotnet restore
-> dotnet build
1dotnet run BLAH # params for the dotnet CLI
2dotnet run -- BLAH # params for the application
1dotnet restore # equivalent of `npm install`
2dotnet build # takes .cs files and compiles into a binary DLL
An assembly in .NET Core is what the output of the C# compiler is, your code in binary format. It’ll be in a folder called bin
(short for binary)
Inside bin/
you’ll have Debug
, which just means this build is easier to debug
1dotnet run # will restore, build, find the .dll and run it
2dotnet bin/Debug/netcoreapp3.0/MyProject.dll # run the assembly manually
The entry point of an application (by convention) is Main()
. dotnet run
will look for a method named Main
and execute the code inside it