Posts

Showing posts with the label dotnet core

Deploy ASP NET Core application on Docker Linux container

Image
Deploy ASP NET Core application on Docker Linux container from Windows Few weeks ago we saw how we could run ASP NET Core application on Ubuntu . This proving that a .NET Core Application can run on a Linux system, today we will be taking it a step further and see how we can deploy our application in a Docker Linux container. This post will be composed by three parts: Install Docker on Windows Docker basic commands Create ASP NET Core application 1. Install Docker on Windows The first step is to go to the official site, sign up and download Docker CE . Once downloaded, install Docker. After being installed you should be able to right click on the icon > Settings on the Docker notification icon and see that Docker is running by checking the status at the bottom left, it should say Docker is running . Open PowerShell and type docker run hello-world . $ docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world...

SDK-Style project and project.assets.json

SDK-Style project and project.assets.json Last week I encountered an issue with MSBuild while trying to run it from command line. The issue did not appear when using VisualStudio right click + build but only appeared when using msbuild.exe CLI directly with a clean project. Assets file 'C:\[...]\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. When I first saw the error, few questions came to my mind which I will share today in 3 points: Overview of project.assets.json Slim SDK-Style project Mixing SDK-Style project and old projects Special shoutout to @enricosada who provided me with all the answers regarding the SDK-Style project. 1. Overview of project.assets.json project.assets.json lists all the dependencies of the project. It is created in the /obj folder when using dotnet restore or dotnet build as it implicitly calls restore before build, or msbuid.exe /t:restore with msbuild CLI. To simulate dotnet build (re...

ApiController attribute in ASP NET Core 2.1

ApiController attribute in ASP NET Core 2.1 ASP NET Core 2.1 brings a set a enhacements for Web API development, Web API being a service accessible via HTTP and returning result in Json format. Those enhancements aim to simplify the composition of those APIs and also remove unecessary functionalities. Today we will explore those enhancements in five parts ControllerBase and ApiController Automatic model validation Inferred model binding ActionResult<T> 1. ControllerBase and ApiController Prior everything, we should set the compatibility version of ASP NET Core by using the .SetCompatibilityVersion . services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); In the past, we used to inherit from Controller which was providing functions to return different HTTP status code results together with optional data like Ok(...) or Json(...) , but it was also used to display Razor views like View(...) or PartialView(...) . Starting from 2.1, it is now recomm...