7.打包打开Inno Setup,通过右上角File->New新建Inno Setup打包文件 。设置应用程序信息
文章插图
设置安装目录为前面的程序发布目录
文章插图
添加卸载快捷键
文章插图
设置licence信息
文章插图
选择安装模式
文章插图
选择汉化语言
文章插图
设置输出目录
文章插图
脚本中添加安装命令 , 卸载命令
[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安装
文章插图
9.检验安装首先去windows 服务查看是否安装成功
文章插图
然后访问服务
文章插图
至此打包安装完成 。
【.NET6打包部署到Windows Service】
推荐阅读
- 图文 Python 嵌入式打包
- docker swarm快速部署redis分布式集群
- 使用 etcdadm 快速、弹性部署 etcd 集群
- Cenots7 离线安装部署PostgreSQL
- 快速安装 服务器之Apollo单机部署
- 云计算_OpenStack
- Docker | redis集群部署实战
- 【番外篇】Rust环境搭建+基础开发入门+Rust与.NET6、C++的基础运算性能比较
- AKS Azure Kubernetes部署及查看应用资源
- asp.net core web 解决方案多项目模板制作打包总结