3

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.

NealGul
  • 101
  • 1
  • 3
  • 13

2 Answers2

3

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

Oofpez
  • 514
  • 1
  • 7
  • 18
  • I'm also using IIS in the same image, can I mention to FROM statements? as in one will be-FROM microsoft/iis and another will be one mentioned by you, is it allowed? – NealGul Jan 11 '19 at 11:51
  • you can use multiple FROM statements, see https://docs.docker.com/develop/develop-images/multistage-build/ by compiling your code and copying the artifacts from the result of one stage to a new stage, you can use multiple base images. – Oofpez Jan 11 '19 at 12:13
  • you could also use COPY to get what you need from a specific, even external image e.g., COPY --from=microsoft/iis:latest . . – Oofpez Jan 11 '19 at 12:18
  • I'll try the same. and will surely be coming back to thank you if it works for me. – NealGul Jan 11 '19 at 12:41
  • It isn't a working man! It shows the error - 'manifest for microsoft/dotnet-framework:4.7.2 not found'. – NealGul Jan 14 '19 at 05:24
  • 2
    perhaps it is FROM microsoft/dotnet-framework:4.7.2-sdk – Oofpez Apr 01 '19 at 14:06
3

So i searched for a few things online and i found out that there is one solution that if i mention to install chocolatey on powershell inside my docker file. This reference, I have received from the this post by anothony chu:

so i used:

# Install Chocolatey
RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command "$env:ChocolateyUseWindowsCompression='false'; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
RUN powershell add-windowsfeature web-asp-net45 \
&& choco install dotnet4.7 --allow-empty-checksums -y \

in my docker file and now all works fine and good.

NealGul
  • 101
  • 1
  • 3
  • 13