Samir Samir - 3 years ago 264
ASP.NET (C#) Question

Upgrading .NET Framework from 4.5 to 4.6 using powershell

We are setting up continuous deployment on our servers and we want it so we have to do as little server customization as possible, so that the powershell script that runs will install everything necessary for a project. So we have a .NET Framework 4.6.1 project but the server only has .NET Framework 4.5 in the Role and Features.

I typically use this to enable all the required stuff:

Enable-WindowsOptionalFeature -online -FeatureName IIS-ISAPIFilter -NoRestart
Enable-WindowsOptionalFeature -online -FeatureName IIS-ISAPIExtensions -NoRestart
Enable-WindowsOptionalFeature -online -FeatureName NetFx4Extended-ASPNET45 -NoRestart
Enable-WindowsOptionalFeature -online -FeatureName IIS-NetFxExtensibility45 -NoRestart
Enable-WindowsOptionalFeature -online -FeatureName IIS-ASPNET45 -NoRestart


How can I install, upgrade or update .NET Framework to be 4.6+ using powershell? I don't see any WindowsOptionalFeatures and everything I find online involves actually downloading things and installing them, not via powershell.

Answer Source

Each OS version brings a different version of preinstalled .NET Framework. The preinstalled version can be activated with the Enable-WindowsOptionalFeature cmdlet. The newer versions needs to be installed separately either with the setup itself

<.NET Framework redistributable> /q /norestart

or some software distribution system. If you want to use Powershell you could take a look at Oneget/Chocolatey as software distribution system.

Install-Package -Name Dotnet4.6.1
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download