Deploy the .NET program to the machine where the .NET FRAMWORK is installed (transfer Zhang Guanghui)

zhaozj2021-02-16  94

This article discusses how to use Windows Installer technology to publish .NET programs, and how to use Native Codes to determine if there is .NET Framework on the target machine;

table of Contents

This article makes your own installer release .NET Framework makes its own Native installer usage method summary

Herein

1. Use vs.net to create an installer.

2. How to deploy .NET Framework to the target machine.

3. How to use Native Codes to make .NET Framework and your own installer as a unified installer. This program does not install .NET Framework automatically if you don't have .NET Framework on the target machine, then automatically install the author's own procedure.

Make your own installer

In VS.NET, we can build our .NET program as a Windows Installer file by building a "Setup and Deployment Projects project) project, very flexible. For example, we can make it easy to customize the following:

1. Whether to place shortcuts on the desktop.

2. Register your own file type, you can use your own program by double-clicking the file.

3. Registry processing

In the following MSDN site, we can get an example of making your own installer through Setup and Deployment Projects in VS.NET:

http://msdn.microsoft.com/library/en-us/vsintro7/html/vbcondeploymentsscenarios.asp

Publish .NET Framework

.NET Framework 1.0 provides an exe file to redeploy .NET: DotNetfx.exe. It contains the incomplete content of Common Language Runtime and other .NET programs.

We can download the exe file from the following site:

Http://msdn.microsoft.com/downloads/sample.asp?url=/msdn-files/027/001/829/msdncompositeoc.xml

At the same time, we can also find the file in the VS.NET installation CD or DVD.

We can deploy .NET Framework to the target machine by running DOTNETFX.EXE:

1. Deploy by Microsoft Systems Management Server.

2. Deploy by Active Directory.

3. Use third-party tools.

For specific information, we can see the following article:

Http://msdn.microsoft.com/library/en-us/dnnetdep/html/redistdeploy.asp

Make your own Native installer

If we want to post your .NET program on the target machine, we are not sure if the target machine has already installed .NET Framework, then we need to design a unmanaged code to determine if the target machine is installed .NET Framework If not, run DOTNETFX.EXE to install .NET Framework, then use Windows Installer to install your own program.

On the MSDN's next page, we can get an installer that uses UNMANAGED C and its source code:

Http://msdn.microsoft.com/downloads/default.asp?url=/code/sample.asp?url=/msdn-files/027/001/830/msdncompositeoc.xml1. In CSETTINGS CLASS, you get your own MSI installation files and DotNetfx.exe path by reading "Settings.ini", and other settings. (Such as the language version of .NET Framework)

GetCaptionText (Void)

GetDialogtext (Void)

GetErrorCaptionText (Void)

Getininame (void)

GetProductName (Void)

The parse () function is used to parse the settings.ini file.

2. In the main.cpp file, the global function fxinstallRequired () determines whether or not to install .NET Framework. FxInstallRequired () on the target machine will detect the version and language settings of the following registry key values ​​and dotnetfx.exe.

HKLM / Software / Microsoft / .Netframework / Policy / V1.0

3. If you need to install .NET Framework, call the following command Silent installation DotNetfx.exe in the global function execcmd ():

DotNetfx.exe / Q: A / C: "Install / L / Q"

4. Call the following command in the Execcmd () global function to install your own MSI file:

Msiexec / I Reboot = ReallySuppress

Instructions

If we use the Native code above as its own installer, we can combine your own .NET program with it by the following steps:

1. Make your own .NET program into a Windows Installer (.msi) file.

2. Open the "Settings.ini" file, set the MSI file path and file name of your .NET program in "MSI" Key; set the path to DotNetfx.exe in "FxInstallerPath" key. For specific parameter information, you can get from the following article:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetdep/html/redistDeploy.asp

3. Install "Setup.exe", "Settings.ini", "DOTNETFX.EXE" and your own MSI installation files, send "setup.exe" and run "setup.exe", and the installer automatically detects if there is. Net Framwork, if not, the DotNetfx.exe will be run first.

With the above steps, you can successfully deploy your own .NET program to a machine that is not installed .NET FRAMWORK environment.

to sum up

With the above steps, you can successfully deploy your own .NET program to a machine that is not installed .NET FRAMWORK environment.

转载请注明原文地址:https://www.9cbs.com/read-12248.html

New Post(0)