Innosetup 設置文件的相對路徑 InnoSetup 以命令行自動編譯打包

在使用innosetup自動化打包的過程當中,若是打包配置文件要隨代碼一塊兒提交,則須要將打包文件改成相對路徑,以便在其它端也能夠直接打包,而不須要再次修改文件路徑參數。html

添加自動化打包文件

1. 添加build文件夾git

 

2. 添加innosetup打包配置文件和cmd命令執行文件,具體能夠參考 InnoSetup 以命令行自動編譯打包github

 3. 雙擊執行autoBuild.bat,便可開始打包app

 

 

配置文件相對路徑設置

先看看當前個人配置文件:ide

 1 #define MyAppName "CompanyUserQuestion"
 2 #define MyAppChineseName "Jira客戶問題"
 3 #define MyAppVersion "1.0"
 4 #define MyAppPublisher "dotnet school"
 5 #define MyAppURL "https://dotnet-campus.github.io/"
 6 #define MyAppExeName "CompanyUserQuestion.exe"
 7 
 8 [Setup]
 9 ; NOTE: The value of AppId uniquely identifies this application.
10 ; Do not use the same AppId value in installers for other applications.
11 ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
12 AppId={{AEDA7675-70DC-479E-B796-344517C2C954}
13 AppName={#MyAppName}
14 AppVersion={#MyAppVersion}
15 ;AppVerName={#MyAppName} {#MyAppVersion}
16 AppPublisher={#MyAppPublisher}
17 AppPublisherURL={#MyAppURL}
18 AppSupportURL={#MyAppURL}
19 AppUpdatesURL={#MyAppURL}
20 DefaultDirName={pf}\{#MyAppName}
21 DefaultGroupName={#MyAppChineseName}
22 OutputDir=F:\GitHub\CompanyUserQuestion\CompanyUserQuestion\build
23 OutputBaseFilename={#MyAppChineseName}
24 SetupIconFile=F:\GitHub\CompanyUserQuestion\CompanyUserQuestion\CompanyUserQuestion\Images\bitbug_favicon.ico
25 Compression=lzma
26 SolidCompression=yes
27 
28 [Languages]
29 Name: "english"; MessagesFile: "compiler:Default.isl"
30 
31 [Tasks]
32 Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
33 
34 [Files]
35 Source: "F:\Gitlab\CompanyUserQuestion\CompanyUserQuestion\CompanyUserQuestion\bin\Debug\CompanyUserQuestion.exe"; DestDir: "{app}"; Flags: ignoreversion
36 Source: "F:\GitHub\CompanyUserQuestion\CompanyUserQuestion\CompanyUserQuestion\bin\Debug\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
37 ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
38 
39 [Icons]
40 Name: "{group}\{#MyAppChineseName}"; Filename: "{app}\{#MyAppName}"
41 Name: "{group}\{cm:UninstallProgram,{#MyAppChineseName}}"; Filename: "{uninstallexe}"
42 Name: "{commondesktop}\{#MyAppChineseName}"; Filename: "{app}\{#MyAppName}"; Tasks: desktopicon
43 
44 [Run]
45 Filename: "{app}\{#MyAppName}"; Description: "{cm:LaunchProgram,{#MyAppChineseName}}";Flags: nowait postinstall skipifsilent

1. 相對路徑post

如上配置文件,是根據innosetup嚮導生成的打包配置,innosetup默認使用的是絕對路徑,如 F:\Gitlab\CompanyUserQuestion\CompanyUserQuestion\CompanyUserQuestion\bin\Debug\CompanyUserQuestion.exe優化

那麼,是否能夠改成相對路徑,更加快捷通用?ui

innosetup支持相對路徑,因此咱們能夠以下修改:this

  • 圖標設置 SetupIconFile=..\CompanyUserQuestion\Images\bitbug_favicon.ico --返回上一層後,再進入CompanyUserQuestion文件夾選擇ico圖標
  • 打包輸出exe目錄 OutputDir=..\build -- 在當前build目錄下生成打包exe;另:若是將OutputDir的設置註釋,則會在build下生成一個output文件夾,打包exe;

其它的文件路徑設置,能夠依照如上設置相對路徑引用。url

2. 程序名參數匹配

在第一步設置中,有CompanyUserQuestion項目名稱,這是不清真的,要統一,因而能夠以下設置:

SetupIconFile=..\{#MyAppName}\Images\Jira.ico

 因此相對路徑優化下,個人配置文件以下:

 1 #define MyAppName "EasinoteUserQuestion"
 2 #define MyAppChineseName "Jira客戶問題"
 3 #define MyAppVersion "1.0"
 4 #define MyAppPublisher "dotnet school"
 5 #define MyAppURL "https://dotnet-campus.github.io/"
 6 
 7 [Setup]
 8 AppId={{AEDA7675-70DC-479E-B796-344517C2C954}
 9 AppName={#MyAppName}
10 AppVersion={#MyAppVersion}
11 AppPublisher={#MyAppPublisher}
12 AppPublisherURL={#MyAppURL}
13 AppSupportURL={#MyAppURL}
14 AppUpdatesURL={#MyAppURL}
15 DefaultDirName={pf}\{#MyAppName}
16 DefaultGroupName={#MyAppChineseName}
17 OutputDir=..\build
18 OutputBaseFilename={#MyAppChineseName}
19 SetupIconFile=..\{#MyAppName}\Images\Jira.ico
20 Compression=lzma
21 SolidCompression=yes
22 
23 [Languages]
24 Name: "english"; MessagesFile: "compiler:Default.isl"
25 
26 [Tasks]
27 Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
28 
29 [Files]
30 Source: "..\{#MyAppName}\bin\Debug\{#MyAppName}.exe"; DestDir: "{app}"; Flags: ignoreversion
31 Source: "..\{#MyAppName}\bin\Debug\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
32 ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
33 
34 [Icons]
35 Name: "{group}\{#MyAppChineseName}"; Filename: "{app}\{#MyAppName}"
36 Name: "{group}\{cm:UninstallProgram,{#MyAppChineseName}}"; Filename: "{uninstallexe}"
37 Name: "{commondesktop}\{#MyAppChineseName}"; Filename: "{app}\{#MyAppName}"; Tasks: desktopicon
38 
39 [Run]
40 Filename: "{app}\{#MyAppName}"; Description: "{cm:LaunchProgram,{#MyAppChineseName}}";Flags: nowait postinstall skipifsilent

提交配置文件,在其它小夥伴的電腦上,雙擊cmd文件,就直接能夠打包最新exe

相關文章
相關標籤/搜索