.Net Core development

Date: 2017-08-28

Source: https://github.com/dotnet/core
Learn: https://docs.microsoft.com/nl-nl/dotnet/core/

Windows
Download: https://www.microsoft.com/net/download/core
Arch Linux
pacaur -S dotnet-sdk-2.0

Create new Solution file

dotnet new sln

Start new project

mkdir $application_name
cd $application_name
dotnet new webapi

Add project to solution
dotnet sln add $project

Reset all nuget packages:
dotnet nuget locals –clear all
info : Clearing NuGet HTTP cache: C:\Users\kooiman\AppData\Local\NuGet\v3-cache
info : Clearing NuGet global packages folder: C:\Users\kooiman\.nuget\packages\
info : Clearing NuGet Temp cache: C:\Users\kooiman\AppData\Local\TempLnk\NuGetScratch
info : Clearing NuGet plugins cache: C:\Users\kooiman\AppData\Local\NuGet\plugins-cache
info : Local resources cleared.
dotnet restore –no-cache –force

List project templates: dotnet new
New WebApi project: dotnet new webapi
Install/restore NuGet packages: dotnet restore
Build project: dotnet build -c Debug
Run project: dotnet run
See it running: http://localhost:5000/api/values

Add NuGet package: dotnet add package Microsoft.EntityFrameworkCore
Add Reference: dotnet add reference lib1/lib1.csproj lib2/lib2.csproj

Command help
dotnet add –help
dotnet add package –help
dotnet add reference –help

Unit Testing
Install nuget package: dotnet add package Microsoft.NET.Test.Sdk

Run unit test: dotnet test
Debug project?

Build release: dotnet build -c Release
Create package: dotnet pack  ~/projects/app1/project.csproj /p:PackageVersion=2.1.0 –no-build –output packages/
Publish nuget package: dotnet nuget push packages/*.nupkg -s http://server.com:123/ -k <API_KEY>
Publish package: dotnet publish ~/projects/app1/project.csproj –framework netcoreapp2.0

Example
mkdir WebApiClient2
cd WebApiClient2

dotnet new classlib -f netcoreapp2.0

dotnet add package Newtonsoft.Json
dotnet add package System.Net.Http

dotnet build -c Debug
:: dotnet build -c Release

dotnet pack -c Release /p:PackageVersion=2.1.0 -o packages/
:: dotnet pack -c Release /p:PackageVersion=2.1.0 –no-build -o packages/

Git

Initialize git: git init
Add git ignore file: .gitignore

Entity Framework

Source : http://www.entityframeworktutorial.net/efcore/cli-commands-for-ef-core-migration.aspx

dotnet ef database drop [arguments] [options]
dotnet ef dbcontext update [arguments] [options]

dotnet ef dbcontext info [arguments] [options]
dotnet ef dbcontext list [arguments] [options]
dotnet ef dbcontext scaffold [arguments] [options]

dotnet ef migrations add [arguments] [options]
dotnet ef migrations list [arguments] [options]
dotnet ef migrations remove [arguments] [options]


Database drop Drops the database.
update Updates the database to a specified migration.
DbContext info Gets information about a DbContext type.
list Lists available DbContext types.
scaffold Scaffolds a DbContext and entity types for a database.
Migrations add Adds a new migration.
list Lists available migrations.
remove Removes the last migration.
script: Generates a SQL script from migrations.

https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-2.2

8410cookie-check.Net Core development