install .net framework 4.7.2 in docker

NealGul picture NealGul · Jan 11, 2019 · Viewed 7.9k times · Source

I'm new to .Net Environment, I'm trying to implement docker here for my firm. They were using 4.5 earlier so I used the following statement in my dockerfile:

RUN Install-WindowsFeature NET-Framework-45-ASPNET ; \
Install-WindowsFeature Web-Asp-Net45

Now, I want to do the same for framework 4.7.2 - I thought it will work if I run the statements like :

RUN Install-WindowsFeature NET-Framework-472-ASPNET ; \
Install-WindowsFeature Web-Asp-Net472

But it's not working this way instead shows the following error :

Install-WindowsFeature : ArgumentNotValid: The role, role service, or feature
name is not valid: 'NET-Framework-472-ASPNET'. The name was not found.
At line:1 char:1
+ Install-WindowsFeature NET-Framework-472-ASPNET ; Install-WindowsFeat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (NET-Framework-472-ASPNET:Strin
   g) [Install-WindowsFeature], Exception
    + FullyQualifiedErrorId : NameDoesNotExist,Microsoft.Windows.ServerManager
   .Commands.AddWindowsFeatureCommand

Please help me with the same. I am really stuck and can't find anything on the internet.

Answer

Oofpez picture Oofpez · Jan 11, 2019

Instead of Installing the NET-Framework yourself, you could use

FROM microsoft/aspnet

or

FROM microsoft/dotnet-framework:4.7.2

to use an image with dotnet framework already installed.

or whatever version you need.

See https://hub.docker.com/u/microsoft/ for all the images on docker hub