Reputation: 101
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.
Upvotes: 3
Views: 20184
Reputation: 101
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.
Upvotes: 3
Reputation: 514
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
Upvotes: 3