- 1. What is C#
- 2. What is .NET
- 3. What is the difference between .NET Framework, .NET Core and .NET?
- 4. How C# is compiled
- 5. Typical dotnet application
- 6. Why Microsoft created .NET?
- 7. .NET Standard
- 8. Deployments options
- 9. Performance
- 10. Commands
- 11. Tools
- C# is a programming language.
- Object Oriented.
- Strongly typed.
- Simple to use and general-purpose.
- Some the things we can write in C#:
- Backend Development (API, EF Core, Linq, Async, OOP)
- Front End (ASP.Net, MVC, Razor, Blazor)
- Mobile (Maui, Xamarin)
- Game (Unity)
- Desktop (Maui, WinForms, WPF)
- A C# compiler.
- A runtime to execute C# (Core CLR).
- Libraries to provide out-of-the-box functionalities (BCL Functions).
- A garbage collector to manage memory.
- .NET (dotnet) is a framework for building applications on Windows, Linux and MAC OS.
- .NET is not limited to C# examples are F# or VB.NET.
- New requirements:
- Cross-platform.
- Open-Source.
- "Similar" to classic .NET.
- Good for cloud, good for microservices -> lightweight and fast.
- PERFORMANCE!!!!
- Almost zero framework overhead = almost zero overhead for your application.
- It's a C# library built on top of .NET: you have the same platform available for your libraries and applications.
- Many C# features and new .NET APIs were "invented" during the development of .NET and ASP.NET to achieve this performance.
- Contract that defines an API surface.
- Versions: 1.0 - 2.0.
- A list of Types and methods that are available in different versions.
- ".NET" flavors implement the standard.
- .NET Standard version are backward compatible.
- Code sharing!
- Target the standard - run everywhere.
- Full framework, .NET Core, Mono (Xamarin): all support .NET Standard 2.0.
- As a library author: you should target .NET Standard (and not e.g. .NET Core).
- PCL and Shared Projects: Previous attempt to share code across .NET Platforms (e.g. Full Framework and Xamarin).
- Recommendation: use .NET Standard.
- Self contained.
- Framework Dependent or Shared Framework.
- .NET application publishing overview
- Contains the CLR.
- No preinstalled framework needed.
- Bigger deployment package which targets a specific OS (The executable is not cross-platform).
dotnet publish --runtime win-x86 --self-contained true
- Only contains the application’s code.
- Requires preinstalled .NET Core on the target machine.
- Cross platform deployment package.
- Small package size.
- Default.
dotnet publish --runtime win-x86 --self-contained false
- Create a Web API into the project
- dotnet new webapi -o
<output_path>
- dotnet new webapi -o
- Add reference to another ClassLib
- dotnet add
<target_project>
reference<project>
# Ex: dotnet add Calculations.Test reference Calculations
- dotnet add
- Step By Step - Create class library into the project
- dotnet new classlib -o Infrastructure
- dotnet sln add "name of classlib"
- dotnet add reference ../classlib/
- Step By Step - Run project
- First enter in the path it contains startup.cs file
- Second run command: dotnet run
- Optional: dotnet watch run
- Restore project, download all dependencies of project
- dotnet restore
- All informations about dotnet in the machine
- dotnet --info
- Build project and generate release
- dotnet publish -c Release
- Verif if machines has https certificate valid
- dotnet dev-certs https
- Trust localhost certificate
- dotnet dev-certs https -t
- List of tools installer with dotnet
- dotnet tool list -g # -g appear globar
- Generate NuGet package
- dotnet pack
- OR
- Adding this tag to automatically generate package on build:
- true
- Create a solution
- dotnet new sln
- Add project into a solution
- dotnet sln add
<dotnet_project>
# Remember, he must exists .csproj file.
- dotnet sln add
- dotnet aspnet-codegenerator --project "D:\CSharp\DotnetDapperOverview\ExampleDapper" controller --force --controllerName CompanyController --model ExampleDapper.Models.Company --dataContext ExampleDapper.Data.ApplicationDbContext --relativeFolderPath Controllers --controllerNamespace ExampleDapper.Controllers
- dotnet tool install --global dotnet-aspnet-codegenerator --version X.X.X