October 08, 2017 by Anuraj
.NET Core Deployment
There are two ways to deploy a .NET Core application. FDD (Framework-dependent deployments) and SCD (Self-contained deployments), a self-contained deployment (SCD) doesn’t rely on the presence of shared components on the target system. All components, including both the .NET Core libraries and the .NET Core runtime, are included with the application and are isolated from other .NET Core applications. This post is about deploying .NET Core application in Self-contained way.
Deploying a Self-contained deployment has two major advantages -
- You have sole control of the version of .NET Core that is deployed with your app. .NET Core can be serviced only by you.
- You can be assured that the target system can run your .NET Core app, since you’re providing the version of .NET Core that it will run on.
To deploy, first you need to create
<RuntimeIdentifiers> tag in the
<PropertyGroup> section of your csproj file that defines the platforms your app targets and specify the runtime identifier (RID) for each platform that you target. You can find the RID catalog in Microsoft docs. The following
<PropertyGroup> section indicates that the app runs on 64-bit Windows 10 operating systems and the 64-bit OS X Version 10.11 operating system.
Next you need to restore the dependencies using
Once restore is completed you can build it in debug mode, so that you can test it and verify it. Once you completed the testing, you can build it in release mode, using
dotnet publish command with release configuration switch. Use the dotnet publish command for both target platforms.
Once publish is completed, you will be able to see the files under publish folder.
If you navigate to the win10-x64 folder, you will be able to see an executable - yourappname.exe (in my case it is SampleApp.exe), you can double click on it to start the application. You can zip the folder and deploy it or you can copy the contents of the folder and deploy it in the server.
Happy Programming :)
Copyright © 2024 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub