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.

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

6 Comments

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?
you can use multiple FROM statements, see 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.
you could also use COPY to get what you need from a specific, even external image e.g., COPY --from=microsoft/iis:latest . .
I'll try the same. and will surely be coming back to thank you if it works for me.
perhaps it is FROM microsoft/dotnet-framework:4.7.2-sdk
|
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.

2 Comments

I used the same solution and stucked at Installing dotnetFX for long. Do you have this problem and how did you solve it ?
@csamleong - I have fixed this problem with the above-mentioned solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.