IIS site file updating method and system, computer equipment and storage medium
By automatically stopping, decompressing and restarting the IIS site through the automatic update program, the problems of high operational risks, hidden dangers of misoperation and low efficiency in the existing technology are solved, and efficient and secure one-click site file updates are achieved.
Patent Information
- Application Number
- CN202510893712.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-30
- Publication Date
- 2025-10-10
AI Technical Summary
The existing IIS site file update process has high operational risks, hidden dangers of misoperation and low efficiency, especially when updating multiple sites, which is time-consuming.
Provided is an IIS site file update method and system, which responds to user operations through an automatic update program, automatically stops the target IIS site, ends the associated process, decompresses the overwritten file and restarts the site, reducing manual intervention.
It achieves one-click efficient updates, reduces operational risks and hidden dangers of misoperation, and significantly saves release time and error probability.
Smart Images

Figure CN120762702A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information technology, and in particular to an IIS site file updating method, system, computer equipment and storage medium. Background Art
[0002] In daily C# back-end WEB API development work, it is often necessary to copy and update the compiled packaged program files to the site folder deployed by IIS to update the site functions. The general operation process is as follows: Taking the update of the Fz.Test.Api site as an example, first compress the local release package into the Fz.Test.Api.zip file package, and then copy it to the corresponding folder of the server (such as D:\IIS_Site_File\Fz.Test.Api). Next, unzip the files in the compressed package and overwrite them to the corresponding site folder of IIS. However, during this process, if a user is accessing the site, replacing Fz.Test.Api.dll may fail, and the system will prompt that the file is being used by other threads and cannot be overwritten.
[0003] In this case, you typically need to perform the following steps: First, log in to the server and open IIS Manager. Find the target website and click "Stop" in the "Website Management" column on the right. After the website is completely stopped, unzip the release package and overwrite the files. After overwriting the files, return to the IIS interface and manually start the site again. Only then can the website API resume providing external services.
[0004] Even if there is no file usage prompt, it is usually necessary to restart the website through IIS after the file is overwritten to ensure timely update of functions. However, this purely manual operation mode has significant disadvantages:
[0005] High operational risk: During the file copying or decompression process, you may accidentally select the wrong directory, causing update failure or affecting other services.
[0006] Misoperation risk: When restarting IIS, the target site may be selected incorrectly due to a large number of sites in the list, causing unnecessary service interruption;
[0007] Inefficiency: Frequent switching between the "stop site → overwrite files → start site" process is required, which is particularly time-consuming when updating multiple sites. Summary of the Invention
[0008] The purpose of the present invention is to provide an IIS site file update method, system, computer equipment and storage medium, aiming to solve the problems of high operation risk, hidden danger of misoperation and low efficiency in existing IIS site file update.
[0009] In a first aspect, an embodiment of the present invention provides an IS site file update method, comprising:
[0010] In response to the user inputting the file package to be updated into the execution directory, triggering the automatic update program;
[0011] Scan the file package to be updated in the execution directory, extract the name of the file to be updated as a target site identifier, and match the target IIS site according to the target site identifier;
[0012] Calling the IIS management interface to stop the target IIS site;
[0013] Calling the system process management interface to query the application pool process associated with the target IIS site and terminate the process;
[0014] Calling a decompression tool to decompress the file to be updated to the physical path of the target IIS site to complete the file overwriting;
[0015] Call the IIS management interface to restart the target IIS site.
[0016] In a second aspect, an embodiment of the present invention provides an IIS site file update system, characterized by including:
[0017] a response unit, configured to trigger an automatic update program in response to a user inputting a file package to be updated into an execution directory;
[0018] a matching unit, configured to scan the file package to be updated in the execution directory, extract the name of the file to be updated as a target site identifier, and match a target IIS site according to the target site identifier;
[0019] A first state configuration unit is used to call the IIS management interface to stop the target IIS site;
[0020] A process termination unit, configured to call a system process management interface to query the application pool process associated with the target IIS site and terminate the process;
[0021] A file overwriting unit is used to call a decompression tool to decompress the file to be updated to the physical path of the target IIS site to complete the file overwriting;
[0022] The second state configuration unit is further used to call the IIS management interface to restart the target IIS site.
[0023] In a third aspect, an embodiment of the present invention provides a computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the IIS site file update method described in the first aspect when executing the computer program.
[0024] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the IIS site file update method described in the first aspect above.
[0025] The beneficial effect of the embodiment of the present invention is that all operations that require manual operation, such as stopping / starting the IIS site, decompressing files, overwriting files, and checking whether the files are overwritten, are handled by the automatic update program (i.e., fz_publish.exe). Users only need to copy the prepared files to be updated to the execution directory and wait for the update results, which greatly reduces the time of publishing operations and the probability of publishing errors. The effect of one-click updating of site files is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0027] Figure 1 A flowchart of a method for updating IIS site files provided by an embodiment of the present invention;
[0028] Figure 2 A schematic diagram of a sub-flow diagram of step S103 provided in an embodiment of the present invention;
[0029] Figure 3 A schematic diagram of a sub-flow diagram of step S105 provided in an embodiment of the present invention;
[0030] Figure 4 A schematic diagram of a sub-flow diagram of step S106 provided in an embodiment of the present invention;
[0031] Figure 5 A schematic block diagram of an IIS site file update system provided by an embodiment of the present invention;
[0032] Figure 6 A schematic block diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0033] The following will provide a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without creative effort shall fall within the scope of protection of the present invention.
[0034] It will be understood that when used in this specification and the appended claims, the terms “comprises” and “comprising” indicate the presence of described features, integers, steps, operations, elements and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0035] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the present invention. As used in the specification and appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0036] It should be further understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0037] See also Figure 1 , Figure 1 A flowchart of a method for updating IIS site files provided by an embodiment of the present invention;
[0038] like Figure 1 As shown, the method includes steps S101 to S106.
[0039] S101, in response to a user inputting a file package to be updated into an execution directory, triggering an automatic update program;
[0040] In this step, the files to be updated are prepared in advance by the user. Through the code and the browser's API documentation (Swagger), you can see the various functions of the site. Select the corresponding functions to be added under the site and compile and package them into a zip file, that is, the pre-prepared files to be updated are obtained;
[0041] In this step, the automatic update program uses fz_publish.exe. fz_publish.exe is a console application written in C# and needs to run in the .NET Core environment.
[0042] S102, scanning the file package to be updated in the execution directory, extracting the name of the file to be updated as a target site identifier, and matching the target IIS site according to the target site identifier;
[0043] In this step, the file packages in the execution directory are automatically scanned by the automatic update program; when only one file package to be updated is scanned, the name of the file package to be updated is extracted as the target site identifier; when multiple file packages to be updated are scanned, the name of the first file package to be updated is selected as the target site identifier; and the target IIS site is matched in the IIS service according to the target site identifier.
[0044] S103: Call the IIS management interface to stop the target IIS site.
[0045] S104, calling the system process management interface to query the application pool process associated with the target IIS site and terminate the process;
[0046] In this step, the automatic update program calls ManagementObjectSearcher, WMI, or PowerShell to query the application pool process ID associated with the target IIS site; and calls Process.Kill() to terminate the remaining process of the target IIS site.
[0047] S105, calling a decompression tool to decompress the file to be updated to the physical path of the target IIS site, completing the file overwriting;
[0048] S106: Call the IIS management interface to restart the target IIS site.
[0049] Steps S102 to S106 are the automatic execution process after the automatic update program is triggered. The user only needs to copy the prepared files to be updated to the execution directory. The automatic update program will automatically stop / start the IIS site, decompress the files, overwrite the files, and check whether the files are overwritten. This allows users to efficiently update site files with one click.
[0050] Based on the above steps S101 to S106, take updating the Fz.Test.Api site as an example; the specific process flow is:
[0051] First, in response to the user placing Fz.Test.Api.zip (i.e., the file package to be updated) into the execution directory (e.g., D:\AutoUpdate);
[0052] Next, the automatic updater detects Fz.Test.Api.zip and extracts the file name Fz.Test.Api as the target site identifier;
[0053] Next, the automatic updater can use the Microsoft.Web.Administration library to match sites with the same name in IIS to determine the Fz.Test.Api site;
[0054] Next, the automatic updater can call the IIS management interface to stop the Fz.Test.Api site;
[0055] Then, the automatic update program can call the decompression tool to decompress Fz.Test.Api.zip to the physical path of the Fz.Test.Api site to complete the corresponding file overwriting;
[0056] Finally, the automatic update program calls the IIS management interface to restart the Fz.Test.Api site, completing the automatic operation of updating the site files.
[0057] In one embodiment, if Figure 2 As shown, step S103 includes:
[0058] S201. Calling a dynamic link library file for interacting with a target IIS site; the dynamic link library file is used to configure, manage, monitor, and process data for the target IIS site;
[0059] S202. Obtain the current site status of the target IIS site through the ServerManager class in the dynamic link library file. The site status includes: starting, started, stopping, stopped, and unknown;
[0060] S203. Use the site.Stop() method of the ServerManager class to stop the target IIS site, and cyclically check the site status until it is confirmed to be in the stopped state.
[0061] In this embodiment, the state control module of the IIS management interface is preferably implemented using a dynamic link library (DLL) file, such as Microsoft.Web.Administration.dll. This DLL file provides comprehensive management functionality for the target IIS site, including but not limited to site creation, deletion, startup, and shutdown, as well as configuration modification. By calling relevant functions within this DLL file, the state control module can flexibly control the target IIS site, ensuring stable operation and efficient management of the target IIS site. Furthermore, using Microsoft.Web.Administration.dll as the DLL file allows full utilization of its rich API interfaces and powerful functionality, further enhancing system reliability and usability.
[0062] In this embodiment, by executing steps S201 to S203, the target IIS site is stopped, and the access function of the target site is disabled, ensuring that subsequent files to be updated will not be occupied by the access thread during the update process, thereby successfully completing the update.
[0063] In this embodiment, the automatic update program is set to stop the target IIS site. Within 30 seconds, the ServerManager class will call site.Stop() every one second to start the target IIS site, and then obtain whether the status of the target IIS site is stopped. If it is not stopped, this operation will be repeated after one second until it succeeds or the 30-second timeout period is reached, and a prompt will be given to end the execution of this method block.
[0064] In one embodiment, if Figure 3 As shown, step S105 includes:
[0065] S301. Obtain the physical path of the file to be updated and use it as the source path;
[0066] S302, obtaining the physical path of the deployment folder of the target IIS site and using it as the target path;
[0067] S303, setting the file overwrite mode of the target IIS site to allow overwriting;
[0068] S304: Using the ExtractToDirectory method in the decompression tool, the source path, the target path, and the overwrite mode are passed in as input parameters to perform the decompression and replacement operations on the files to be updated.
[0069] In this embodiment, the ExtractToDirectory method can be used for decompression. The ExtractToDirectory method is a method in the ZipFile class, a decompression tool. This method is used to extract the files to be updated into the physical path of the deployment folder specified by the target IIS site. When performing the decompression and replacement operation, the system first checks whether there is a file with the same name as the file to be updated in the physical path of the deployment folder. If so, the system determines based on the set overwrite mode. If the overwrite mode is set to allow overwriting, the file with the same name in the physical path of the deployment folder is directly replaced.
[0070] In one embodiment, after step S105, the method further includes:
[0071] Check whether the file to be updated is overwritten successfully; if successful, return the update success information and delete the file to be updated in the execution directory; if unsuccessful, return the failure information and return the corresponding prompt information in response to the user's query operation.
[0072] In this embodiment, whether the file to be updated is successfully overwritten can be detected by checking the hash value or size of the file, etc. If the overwriting is successful, the system generates and returns an update success information to the user, and then automatically deletes the file to be updated in the execution directory to save the space in the execution directory. If the overwriting is not successful, the system records and returns a failure information, and when the user inquires the update status, the system responds and returns the detailed failure reason or operation prompt so as to allow the user to perform corresponding processing.
[0073] In one embodiment, as shown in FIG. 1, step S106 includes: Figure 4
[0074] S401, calling a dynamic link library file for interacting with the target IIS site; the dynamic link library file is used for performing configuration, management, monitoring and data processing of the target IIS site;
[0075] S402, obtaining the current site state of the target IIS site through a ServerManager class in the dynamic link library file, the site state including: starting, started, stopping, stopped and unknown;
[0076] S403, starting the target IIS site by using a site.Start() method of the ServerManager class, and cyclically detecting the site state until confirming that the site state is the started state.
[0077] In this embodiment, after the file to be updated completes the file overwriting, the running of the target IIS site is restarted through the dynamic link library file, and then the access function of the target IIS site is recovered.
[0078] In this embodiment, when the automatic update program starts the target IIS site, the ServerManager class calls the site.Start() to start the target IIS site every second within 30 seconds, and then whether the state of the target IIS site is the started state is obtained. If the state is not the started state, the operation is repeated after one second, until the operation is successful or the timeout time of 30 seconds is reached to give a prompt to end the method block.
[0079] The embodiment of the application further provides an IIS site file updating system, which is used for executing any one of the embodiments of the IIS site file updating method. Specifically, please refer to Figure 5 , Figure 5 is a schematic block diagram of the IIS site file updating system provided by the embodiment of the application.
[0080] As shown in FIG. 1, the IIS site file updating system includes: Figure 5 As shown, the IIS site file update system 500 includes: a response unit 501, a matching unit 502, a first state configuration unit 503, a process termination unit 504, a file overwriting unit 505 and a file overwriting unit 506.
[0081] A response unit 501 is configured to trigger an automatic update program in response to a user inputting a file package to be updated into an execution directory;
[0082] The matching unit 502 is used to scan the file package to be updated in the execution directory, extract the name of the file to be updated as the target site identifier, and match the target IIS site according to the target site identifier;
[0083] The first state configuration unit 503 is used to call the IIS management interface to stop the target IIS site;
[0084] The process termination unit 504 is used to call the system process management interface to query the application pool process associated with the target IIS site and terminate the process;
[0085] The file overwriting unit 505 is used to call a decompression tool to decompress the file to be updated to the physical path of the target IIS site to complete the file overwriting;
[0086] The second state configuration unit 506 is further configured to call the IIS management interface to restart the target IIS site.
[0087] In this system, all manual operations, such as stopping / starting the IIS site, decompressing files, overwriting files, and checking whether the files have been overwritten, are handled by the automatic update program (i.e., fz_publish.exe). Users only need to copy the prepared files to be updated to the execution directory and wait for the update results, which greatly reduces the time and probability of publishing errors. This achieves the effect of a one-click update of site files.
[0088] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0089] The above IIS site file update system can be implemented in the form of a computer program. The computer program can be installed in Figure 6 Runs on the computer device shown.
[0090] See also Figure 6 , Figure 6 6 is a schematic block diagram of a computer device provided by an embodiment of the present invention. The computer device 600 is a server, which can be an independent server or a server cluster composed of multiple servers.
[0091] See Figure 6 The computer device 600 includes a processor 602 , a memory, and a network interface 605 connected via a system bus 601 , wherein the memory may include a non-volatile storage medium 603 and an internal memory 604 .
[0092] The non-volatile storage medium 603 can store an operating system 6031 and a computer program 6032. When the computer program 6032 is executed, the processor 602 can execute the IIS site file update method.
[0093] The processor 602 is used to provide computing and control capabilities to support the operation of the entire computer device 600.
[0094] The internal memory 604 provides an environment for the operation of the computer program 6032 in the non-volatile storage medium 603. When the computer program 6032 is executed by the processor 602, the processor 602 can execute the IIS site file update method.
[0095] The network interface 605 is used for network communication, such as providing data information transmission. Those skilled in the art will understand that Figure 6 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present invention, and does not constitute a limitation on the computer device 600 to which the solution of the present invention is applied. The specific computer device 600 may include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0096] Those skilled in the art will understand that Figure 6 The embodiment of the computer device shown in the figure does not constitute a limitation on the specific composition of the computer device. In other embodiments, the computer device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. For example, in some embodiments, the computer device may only include a memory and a processor. In such an embodiment, the structure and function of the memory and processor are the same as those in the figure. Figure 6 The embodiments shown are consistent and will not be described again here.
[0097] It should be understood that in the embodiment of the present invention, the processor 602 may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0098] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium may be a non-volatile computer-readable storage medium. The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the IIS site file update method according to an embodiment of the present invention is implemented.
[0099] The storage medium is a physical, non-transient storage medium, for example, a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, etc., which can store program codes.
[0100] Those skilled in the art will clearly understand that, for the sake of convenience and brevity of description, the specific working processes of the above-described devices, systems and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0101] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and such modifications or substitutions are intended to be within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.
Claims
1. A method for updating IIS site files, characterized in that: include: In response to the user inputting the file package to be updated into the execution directory, triggering the automatic update program; Scan the file package to be updated in the execution directory, extract the name of the file to be updated as a target site identifier, and match the target IIS site according to the target site identifier; Calling the IIS management interface to stop the target IIS site; Call the system process management interface to query the application pool process associated with the target IIS site and end the process; Calling a decompression tool to decompress the file to be updated to the physical path of the target IIS site to complete the file overwriting; Call the IIS management interface to restart the target IIS site.
2. The IIS site file update method according to claim 1, characterized in that: The scanning of the to-be-updated file package in the execution directory, extracting the name of the to-be-updated file as a target site identifier, and matching a target IIS site according to the target site identifier includes: Scan the file packages in the execution directory; When only one file package to be updated is scanned, extracting the name of the file package to be updated as a target site identifier; When multiple file packages to be updated are scanned, the name of the first file package to be updated is selected as the target site identifier; The target IIS site is matched in the IIS service according to the target site identifier.
3. The IIS site file update method according to claim 1, characterized in that: The calling of the IIS management interface to stop the target IIS site includes: Calling a dynamic link library file that interacts with the target IIS site; the dynamic link library file is used to perform configuration, management, monitoring and data processing on the target IIS site; Obtain the current site status of the target IIS site through the ServerManager class in the dynamic link library file, where the site status includes: starting, started, stopping, stopped, and unknown; The target IIS site is stopped by using the site.Stop() method of the ServerManager class, and the site status is detected cyclically until it is confirmed to be in a stopped state.
4. The IIS site file update method according to claim 1, characterized in that: The calling of the system process management interface to query the application pool process associated with the target IIS site and terminating the process includes: Call ManagementObjectSearcher, WMI, or PowerShell to query the application pool process ID associated with the target IIS site; Call Process.Kill() to terminate the residual process of the target IIS site.
5. The IIS site file update method according to claim 1, characterized in that: The calling of the decompression tool to decompress the file to be updated to the physical path of the target IIS site to complete the file overwriting includes: Obtain the physical path of the file to be updated and use it as the source path; Obtain the physical path of the deployment folder of the target IIS site and use it as the target path; Set the file overwrite mode of the target IIS site to allow overwriting; The source path, target path and overwrite mode are passed as input parameters through the ExtractToDirectory method in the decompression tool to perform the decompression and replacement operation of the file to be updated.
6. The IIS site file update method according to claim 1, characterized in that: The calling of the IIS management interface to restart the target IIS site includes: Calling a dynamic link library file that interacts with the target IIS site; the dynamic link library file is used to perform configuration, management, monitoring and data processing on the target IIS site; Obtain the current site status of the target IIS site through the ServerManager class in the dynamic link library file, where the site status includes: starting, started, stopping, stopped, and unknown; The target IIS site is started by using the site.Start() method of the ServerManager class, and the site status is detected cyclically until it is confirmed to be started.
7. The IIS site file update method according to claim 1, characterized in that: After calling the decompression tool to decompress the file to be updated to the physical path of the target IIS site and completing the step of overwriting the file, the method further includes: Detecting whether the file to be updated is successfully overwritten; If successful, the update success information is returned and the files to be updated in the execution directory are deleted; If unsuccessful, a failure message is returned, and corresponding prompt information is returned in response to the user's query operation.
8. An IIS site file update system, characterized in that: include: a response unit, configured to trigger an automatic update program in response to a user inputting a file package to be updated into an execution directory; a matching unit, configured to scan the file package to be updated in the execution directory, extract the name of the file to be updated as a target site identifier, and match a target IIS site according to the target site identifier; A first state configuration unit is used to call the IIS management interface to stop the target IIS site; A process termination unit, configured to call a system process management interface to query the application pool process associated with the target IIS site and terminate the process; A file overwriting unit is used to call a decompression tool to decompress the file to be updated to the physical path of the target IIS site to complete the file overwriting; The second state configuration unit is further used to call the IIS management interface to restart the target IIS site.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the IIS site file updating method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, causes the processor to execute the IIS site file updating method according to any one of claims 1 to 7.