Understanding Git Garbage Collection

Garbage collection is a well known software practice. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program. When we talk about the Git Garbage Collection, we mean almost the same thing. Git garbage collector runs a number of housekeeping tasks within the current repository, such as compressing file revisions (to reduce disk space and increase performance), removing unreachable objects which may have been created from prior invocations of git add, packing refs, pruning reflog or stale working trees.
Continue reading “Understanding Git Garbage Collection”

Publishing Dotnet Core creates multiples nested directories

This is one of the errors that we encountered in the ASP.NET core build process. To this date, this issue can be easily reproduced by creating a ASP.NET core web api process and repeating ‘dotnet publish’ command with using an output directory and parameter –output. However, it does not happen with the simple console applications.

When we try to publish files, it creates nested multiple output directories like below:

Dotnet Core Publish creates multiple nested output directories
Continue reading “Publishing Dotnet Core creates multiples nested directories”

Dockerfile Naming Convention and Organization

Docker files are used to create docker images. When you are building image using Dockerfile, by default it would search for a file named Dockerfile with no file extension in the current directory context. Now normally an application have multiple environments like Dev, QA, Production etc. Few things like application settings and environmental variables will generally differ from one environment to another environment. To account for these changes and for image to work properly in these different environments, it needs to be either generic in nature (which is a very rare case and puts lots of un-necessary modification in the application code itself to account for these changes at runtime) or images needs to built for each environment separately.
Continue reading “Dockerfile Naming Convention and Organization”

Deploy ASP.NET Core App as Azure Containers Instances (ACI)

Microsoft has invested billions in Azure to drive technology and also hired best of the minds on this planet. From last few months, Azure has been launching new container-focused products and services on a regular basis. One of these products is Azure Container Instances. It acts as a bridge between platform as a service and infrastructure as a service architecture. Perhaps it would be okay to call this service as “Container as a Service”. Azure Container Instances (ACI) allows to rapidly create and launch containerized applications, without any overhead and with an easily scriptable set of commands. Designed to work both on its own and with tools like Kubernetes, ACI adds container-management commands to Azure, coupling them with a billing model that’s based on per-second usage, with no need to create and deploy (and pay for) container hosts. In this blog post, we’ll create an ASP.NET Core App, containerize it and deploy it as single instance on ACI.   Continue reading “Deploy ASP.NET Core App as Azure Containers Instances (ACI)”

ASP.NET Core App fails to start with error: ‘A path base can only be configured using IApplicationBuilder.UsePathBase().’

In one of the cases with setting up builds for new source code repositories we came across this issue. One of the microservices was written in ASP.NET core using Visual Studio. It was working fine using Visual Studio or when hosted using IIS, but it fails to start with below error when using dotnet native command inside docker image. The error message was like below:

System.InvalidOperationException: A path base can only be configured using IApplicationBuilder.UsePathBase().
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.d__7.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Continue reading “ASP.NET Core App fails to start with error: ‘A path base can only be configured using IApplicationBuilder.UsePathBase().’”

Build ASP.NET Core Web App and deploy as Azure Web App on Containers

Azure Web Apps or Azure App Service Web Apps or simply Azure Websites is a PaaS service from Microsoft Azure which can be used to host web apps or APIs build using a variety of programming languages like ASP.NET, ASP.NET Core, Java, Ruby, PHP etc. It is also optimized for hosting web applications and containers, in case the SDK version required is not already supported by Web Apps. Rather than using ACS (Azure Container Services) and AKS (Azure Kubernetes Service), Azure Web Apps are more suitable for deploying long running containers. Also they become more affordable in terms of pricing as compared to the ACS and AKS. In this post, we’ll discuss how to create a very basic ASP.NET Core App and then deploy it as a container on Azure Web App.  Continue reading “Build ASP.NET Core Web App and deploy as Azure Web App on Containers”

Dotnet Core 2.0 build fails with Error MSB4062: The “GetDotNetHost” task could not be loaded from the assembly

We were recently observing this issue with one of the new source code repositories for a solution that was written in .NET Core 2.0. The source code was coded using Visual Studio and it was working fine on the developers machine. However, when building it using dotnet core publish task, it kept failing with below error:

T12:47:54.2728059Z C:\Windows\ServiceProfiles\NetworkService.nuget\packages\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.4\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets(45,5): error MSB4062: The “GetDotNetHost” task could not be loaded from the assembly C:\Windows\ServiceProfiles\NetworkService.nuget\packages\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.4\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Tasks.dll. Assembly with same name is already loaded Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask
Continue reading “Dotnet Core 2.0 build fails with Error MSB4062: The “GetDotNetHost” task could not be loaded from the assembly”