.NET6打包部署到Windows Service( 二 )

7.打包打開Inno Setup,通過右上角File->New新建Inno Setup打包文件 。設置應用程序信息

.NET6打包部署到Windows Service

文章插圖
設置安裝目錄為前面的程序發布目錄
.NET6打包部署到Windows Service

文章插圖
添加卸載快捷鍵
.NET6打包部署到Windows Service

文章插圖
設置licence信息
.NET6打包部署到Windows Service

文章插圖
選擇安裝模式
.NET6打包部署到Windows Service

文章插圖
選擇漢化語言
.NET6打包部署到Windows Service

文章插圖
設置輸出目錄
.NET6打包部署到Windows Service

文章插圖
腳本中添加安裝命令 , 卸載命令
[Run]Filename: "{sys}\sc.exe"; Parameters: "stop MyService" ; Flags: runhiddenFilename: "{sys}\sc.exe"; Parameters: "delete MyService" ; Flags: runhiddenFilename: "{sys}\sc.exe"; Parameters: "create MyService start=auto binPath=""{app}\MyWeb.exe""" ; Flags: runhiddenFilename: "{sys}\sc.exe"; Parameters: "start MyService" ; Flags: runhidden[UninstallRun]Filename: "{sys}\sc.exe"; Parameters: "stop MyService" ; Flags: runhiddenFilename: "{sys}\sc.exe"; Parameters: "delete MyService" ; Flags: runhidden腳本最終內容
; Script generated by the Inno Setup Script Wizard.; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!#define MyAppName "MyService"#define MyAppVersion "1.0.0"#define MyAppPublisher "My Company, Inc."#define MyAppURL "https://www.example.com/"[Setup]; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)AppId={{0C9603FD-2587-41FD-A532-CB5294E7B56E}AppName={#MyAppName}AppVersion={#MyAppVersion};AppVerName={#MyAppName} {#MyAppVersion}AppPublisher={#MyAppPublisher}AppPublisherURL={#MyAppURL}AppSupportURL={#MyAppURL}AppUpdatesURL={#MyAppURL}DefaultDirName={autopf}\{#MyAppName}DefaultGroupName={#MyAppName}DisableProgramGroupPage=yesLicenseFile=D:\Mylicence.txtInfoBeforeFile=D:\Myshowafter.txtInfoAfterFile=D:\Myshowbefore.txt; Uncomment the following line to run in non administrative install mode (install for current user only.);PrivilegesRequired=lowestOutputDir=C:\Users\c\DesktopOutputBaseFilename=mysetupCompression=lzmaSolidCompression=yesWizardStyle=modern[Languages]Name: "chinese"; MessagesFile: "compiler:Languages\Chinese.isl"[Files]Source: "D:\MyWeb\bin\Release\net6.0\publish\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; NOTE: Don't use "Flags: ignoreversion" on any shared system files[Icons]Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"[Run]Filename: "{sys}\sc.exe"; Parameters: "stop MyService" ; Flags: runhiddenFilename: "{sys}\sc.exe"; Parameters: "delete MyService" ; Flags: runhiddenFilename: "{sys}\sc.exe"; Parameters: "create MyService start=auto binPath=""{app}\MyWeb.exe""" ; Flags: runhiddenFilename: "{sys}\sc.exe"; Parameters: "start MyService" ; Flags: runhidden[UninstallRun]Filename: "{sys}\sc.exe"; Parameters: "stop MyService" ; Flags: runhiddenFilename: "{sys}\sc.exe"; Parameters: "delete MyService" ; Flags: runhidden8.打包編譯點擊編譯按鈕,打包好后,雙擊exe安裝
.NET6打包部署到Windows Service

文章插圖
9.檢驗安裝首先去windows 服務查看是否安裝成功
.NET6打包部署到Windows Service

文章插圖
然后訪問服務
.NET6打包部署到Windows Service

文章插圖
至此打包安裝完成 。
【.NET6打包部署到Windows Service】

推薦閱讀