I have a Windows service built using .NET Framework (version 4.6.2). It was made using the "Windows Service (.NET Framework)" template in Visual Studio 2017. For reference, I followed this guide .
A custom installer will be made to install/update/maintain this Windows service on client machines. Here's an overview of the installer:
As far as I can tell, when the service is started, .NET Framework 4.6.2 needs to already be installed on the machine for the service to work.
How do I make certain that the client's machine has .NET Framework 4.6.2 installed on it?
Also, will other versions of .NET Framework - for example version 4.8 - already installed on the machine cause issues?
I did some searching online, but haven't found any solutions for my situation. This solution only works if we decide to use the Visual Studio Installer project for our installer. Self-contained deployments apparently only work for projects based on .NET Core, not .NET Framework.
Although we haven't yet implemented our custom installer, after some research, here is what we will most likely do:
Have our custom installer check for an existing version of .NET Framework. See this document for details on determining an installed version of .NET Framework.
If the client has an older version of .NET Framework installed, then ask them if they want to update to version 4.6.2. If they decline, abort the custom installer. If they choose to update to .NET Framework version 4.6.2, then we will invoke the offline installer. See the basic code example below invoking the offline installer:
// NOTE: This code is just a crude example. // Invoke the offline installer. System.Diagnostics.Process process = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; startInfo.FileName = "cmd.exe"; startInfo.Arguments = "/C path\\\\to\\\\offline\\\\installer\\\\NDP462-KB3151800-x86-x64-AllOS-ENU.exe"; process.StartInfo = startInfo; process.Start(); process.WaitForExit(); // Handle the exit code. if (process.ExitCode == ...) { ... }
The following was found during some of my testing/research:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.