The SDK ‘Microsoft.Docker.Sdk’ specified could not be found and other .NET Core/Docker fun…

This is a brief post because it’s the second time I’ve had to resolve the same issue and as I don’t think my memory is getting any better, it’s probably better this goes down on my permanent record. 😉

I love those rabbit holes that you don’t see coming until too late. I had offered to assist with some Docker investigations for another Technical Evangelist at Microsoft. In order to do that I needed to take a currently functional ASP.NET Core site and add docker support.

So easy… Right click to win…

After Visual Studio added the DockerFile and the Docker-Compose scripts, I clicked on the Continuous Delivery Extension and configured the release to deploy using an Azure App Service for Linux. The resulting build would submit a Docker Image to my Azure Container Registry and the Azure App Service for Linux would host this as content. This approach is really attractive as we benefit from the enhanced DevOps story as well as benefiting from features such as SSL termination and App Settings integration.

The extension usually performs a rapid job of created the App Service, generated a .NET Core build and provisioned a release to to the App Service.

To my disappointment, my first build instead resulted in the following error:

/usr/share/dotnet/sdk/1.1.4/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.TargetFrameworkInference.targets(112,5): error : The current .NET SDK does not support targeting .NET Core 2.0. Either target .NET Core 1.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.0. [/src/DevRiseContainer/DevRise.csproj]

As my ASP.NET Core project was targeting version 2.0, the line above rightly indicated that the image being chosen for the build was incorrect. I searched through the code for the image being specified (microsoft/aspnetcore-build:1.0-1.1) and found it in the docker-compose.ci.build.yml file. I updated the image value to microsoft/aspnetcore:2.0 and restarted the build.

The lines in the middle were being reported because the image I had specified only contained the run-time and wasn’t suitable for building ASP.NET Core applications. I updated the image to microsoft/aspnetcore-build:2.0 and queued another build.

To my frustration it failed again with an error that looked almost identical to one we had just resolved.

Some further research found that this is the result of a known issue in the command-line tooling. I simply had to update the image one last time to a custom image, microsoft/aspnetcore-build:1.0-2.0 that the .NET Core team had created to enable the CI build with Visual Studio.

With a successful build, the continuous deployment then fired and configured our App Service for Linux to point at the delivered container in the Azure Container Registry.

I find it really interesting that these kind of posts are the ones that readers will hit the most. I just hope this post finds people with the same issues I had so you can get back to creating value instead of tricking your tools into working.

Search

Search for:

Text Widget

This is a text widget, which allows you to add text or HTML to your sidebar. You can use them to display text, links, images, HTML, or a combination of these. Edit them in the Widget section of the Customizer.