Tuesday, January 8, 2019

Deploying .NET Core Applications

Depending on the type of application and the target environment .Net core offers different types of packaging and deployment. Mainly there are 2 types of deployment framework-dependent deployment and self-contained deployment.

Framework-dependent deployment:
This type of deployment is suitable for environments where the target machines already have the .Net Core. These deployments package only the application files, the application gets executed using the pre-existing .Net Core in the target machines. Since this deployment contains only Application files and not framework files, the size of the package will be smaller. For framework dependent deployment we have to use the –f switch to the publish command as follows.

dotnet publish -f <framework>

Self-contained deployment:
This deployment is suitable to environments, which don’t have the .Net Core runtime in the target machines. This deployment package includes the application binaries and the .Net Core libraries required to run the application. Since the package includes the .Net Core runtime files, the size of the package will be larger than that of Framework-dependent deployment packages.  For Self-contained deployment we have to use the –r switch to the publish command as follows.

dotnet publish -r <runtime>

Deploying applications with 3rd party dependencies:
The above commands will package the applications without any 3rd party dependency libraries, if the application to be deployed has any 3rd party dependencies then we need to do 2 additional steps.

First we need to add an <ItemGroup> entry for the 3rd party dependency in the project file .csproj, with the specification of the 3rd party dependency.

<ItemGroup>
    <PackageReference Include="<library name>" Version="<version>" />
</ItemGroup>

Next we need to make sure that the NuGet package containing the dependent library is downloaded to the build machine where we run the publish command.

Search Flipkart Products:
Flipkart.com

No comments: