Alvin
Alvin

Reputation: 302

Docker Image for Windows server 2016 with framework .NET 5.0

We have Docker installed on Windows Server 2016. The application we have is in .NET 5.0 using VS 2019 IDE. I couldn't get Docker container up and running using below code. The installation of VS 2019 build tools fails. Any help is highly appreciated.

Things I tried:

  1. Installing .NET 5.0 (sdk/runtime) seems to be successful but the dotnetfx (exit code 3010) requires reboot which is the root cause. Because of this pending reboot, the installation of VS 2019 build tools fails.
  2. I tried using other images but getting daemon related error. Looks like I am unable to find Docker image which has .NET 5.0 installed for windows server 2016 host

DockerFile:

# escape=`
FROM mcr.microsoft.com/windows/servercore:1607
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]


# Install Chocolatey
RUN write-host "*********** Chocolatey Install"
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))


# Install Nuget
RUN write-host "*********** NuGet Install"
RUN choco install nuget.commandline --version=5.11.0


# Install .net 5.0 framework
# RUN write-host "*********** Install .Net 5.0"
RUN choco install dotnet-5.0-sdk --version=5.0.402 --yes


# Download and Install Build Tools
RUN write-host "*********** Download and Install Build Tools 2019"
RUN choco install visualstudio2019buildtools --version=16.11.5.0 --yes

Error:

Installed:

  • dotnetfx v4.8.0.20190930
  • chocolatey-visualstudio.extension v1.10.0
  • visualstudio-installer v2.0.2
  • chocolatey-dotnetfx.extension v1.0.1

Packages requiring reboot:

  • dotnetfx (exit code 3010)

The recent package changes indicate a reboot is necessary. Please reboot at your earliest convenience.

Failures

  • visualstudio2019buildtools (exited -1) - Error while running 'C:\ProgramData\chocolatey\lib\visualstudio2019buildtools\tools\ChocolateyInstall.ps1'.

Upvotes: 0

Views: 1138

Answers (1)

Matt Thalman
Matt Thalman

Reputation: 3965

I don't know how choco handles the installation of VS Build Tools so I can't say for sure how to avoid the restart requirement.

However, you should be able to avoid creating your own image and instead use the existing mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2016 image. This actually provides everything you need:

Upvotes: 2

Related Questions