.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】

推荐阅读