一、準(zhǔn)備工作
1 Visual Studio 2015 必須有相關(guān)的打包組件;
2 Visual Studio的打包組件有 InstallShield 和 Visual Studio Installer Projects (安裝包:VSI_bundle)組件;
3 Visual Studio Installer Projects還可在VS軟件中下載,下載方式如下:
a)點(diǎn)中菜單欄的“工具”選項(xiàng),并選中“擴(kuò)展和更新”;
b)在搜索框輸入 Visual Studio Installer Projects ,然后選中Visual Studio Installer Projects 安裝。
二、使用 Visual Studio Installer Projects 打包項(xiàng)目
1、 創(chuàng)建項(xiàng)目,可在菜單欄點(diǎn)擊 文件——>新建——>項(xiàng)目,也可在當(dāng)前解決方案上右鍵,然后選擇 添加——>新建項(xiàng)目
2 選中 其他項(xiàng)目類型 ——> Visual Studio Installer ——>Setup Project ,然后編輯 名稱 和 位置 。
3 新建的 工程文件 如下圖所示。
工程中包含三個文件夾:
Application Folder:存放打包項(xiàng)目包含的所有文件;
User‘s Desktop:存放安裝后要置于桌面的文件;
User’s Programs Menu:存放安裝后在“開始菜單”內(nèi)顯示的文件;
4 打包文件包含可執(zhí)行exe(或項(xiàng)目主輸出)文件及項(xiàng)目運(yùn)行包含的腳本、外部添加的dll文件等相關(guān)依賴項(xiàng)。
添加方法:
a)點(diǎn)中 “Application Folder” 選項(xiàng),然后右擊,移動至“Add”上;
Folder:添加文件夾;
項(xiàng)目輸出:可添加項(xiàng)目的輸出文件;
文件:項(xiàng)目運(yùn)行包含的腳本、外部添加的dll文件等;
程序集:添加項(xiàng)目依賴項(xiàng),一般在“文件”處就添加了。
b)添加項(xiàng)目主輸出文件,點(diǎn)擊 “項(xiàng)目輸出”,在“項(xiàng)目”處選擇需要打包的項(xiàng)目,點(diǎn)中“主輸出”,然后點(diǎn)中“確定”。(這里添加項(xiàng)目生成的 .exe 文件也是一樣的)
c)添加程序運(yùn)行需要的 腳本及外部添加dll文件 等,右擊 “Application Folder” 文件夾空白處,選擇需要添加的 文件和文件夾。
d)添加 快捷方式
1、選中“主輸出”文件或添加的 “.exe” 文件,右擊選擇 “Create Shortcut to” ;
2、點(diǎn)擊生成的文件,將其移動至 “User‘s Desktop” ;
3、在 “User’s Programs Menu” 中新建Folder,生成一個文價夾;
4、回到 “Application Folder” 文件夾,選中“主輸出”文件或添加的 “.exe” 文件,右擊選擇 “Create Shortcut to” ;
5、點(diǎn)擊生成的文件,將其移動至 “User’s Programs Menu” 生成的文件夾中;
e)添加卸載程序的exe文件
1、右擊 “Application Folder” 文件夾空白處,找到 “msiexec.exe”文件,在路徑處粘貼 “C:\Windows\System32” ,找到 “msiexec.exe” 文件,點(diǎn)擊 “打開”。
2、選中“msiexec.exe”文件,右擊選擇 “Create Shortcut to” ,并將生成的文件名改為 “uninstall” ;
如下圖所示。
3、選中 解決方案資源管理器 中的打包項(xiàng)目,復(fù)制 屬性的ProductCode 值。
4、選中 “uninstall” ,將復(fù)制的 ProductCode 值粘貼至 “uninstall” 屬性的 Arguments處,并在最前面添加 /x及一個英文空格。
f)添加程序圖標(biāo)(應(yīng)用程序及卸載程序)
1、選中需要更該的應(yīng)用圖標(biāo)。
2、點(diǎn)中 屬性框中Icon ,選中 (Browse … …)
3、在彈出窗口中 點(diǎn)擊 Browse
4、雙擊 “Application Folder”
5、選中 添加的 ico 文件
6、點(diǎn)擊 OK
g)更改應(yīng)用在 “卸載或更改程序” 中的圖標(biāo)
選中打包項(xiàng)目文件,在 “AddRemoveProgramsIcon” 項(xiàng)按f)步驟更改圖標(biāo)。
h)更改安裝文件路徑
選中 “Application Folder” ,在 DefaultLocation 處 將[ProgramFilesFolder][Manufacturer][ProductName] 改為 C:[Manufacturer][ProductName],安裝文件夾由 C:\Program Files[Manufacturer][ProductName] 改為C:[Manufacturer][ProductName] 。
i)設(shè)置setup的啟動條件,判斷net是否安裝
一般打包的應(yīng)用程序運(yùn)行框架中,會依賴“. net Framework”版本環(huán)境,所以為確保應(yīng)用安裝并正常運(yùn)行須先保證系統(tǒng)配置有指定版本及以上版本的依賴項(xiàng)。
1、選中項(xiàng)目,右擊——>View——>啟動條件
2、選中 Net Framework ,在其屬性頁 Version 項(xiàng),選擇對應(yīng)的 .Net Framework版本。
j)配置完成,生成項(xiàng)目安裝包
1、選中 打包項(xiàng)目,右擊,點(diǎn)擊生成。
2、生成后的問件夾。
3、生成后Debug包
三、其它
1 打開打包項(xiàng)目的文件系統(tǒng)
2 主輸出或exe的屬性文章來源:http://www.zghlxwxcb.cn/news/detail-445982.html
序號 | 名稱 | 中譯 |
---|---|---|
1 | Condition | 條件 |
2 | Dependencies | 依賴 |
3 | Exclude | 排除 |
4 | Exclude Filter | 排除篩選器 |
5 | Folder | 文件夾 |
6 | Hidden | 隱藏 |
7 | Key Output | 鍵輸出 |
8 | Outputs | 輸出 |
9 | Package As | 打包為 |
10 | Permanent | 永久 |
11 | Read Only | 只讀 |
12 | Register | 注冊 |
13 | Shared Legacy | 共享遺產(chǎn) |
14 | System | 系統(tǒng) |
15 | Transitive | 及物 |
16 | vital | 重要 |
3 打包項(xiàng)目的屬性各項(xiàng)涵義文章來源地址http://www.zghlxwxcb.cn/news/detail-445982.html
序號 | 名稱 | 解釋 | 中譯 | 譯文 |
---|---|---|---|---|
1 | Add Remove Programs Icon | Specifies an icon to be displayed in the Add/Remove Programs dialog box on the target computer. | “添加/刪除程序”對話框中顯示的圖標(biāo) | 指定要在目標(biāo)計(jì)算機(jī)上的“添加/刪除程序”對話框中顯示的圖標(biāo)。 |
2 | Author | Specifies the name of the author of an application or component. | 作者 | 指定應(yīng)用程序或組件的作者姓名。 |
3 | Backward compatible ID Generation | True specifies Visual Studio 2008 (and earlier) lD generation; False specifies Visual Studio 2010 ID generation. | 向后兼容的 ID生成True | 指定 Visual Studio 2008(及更早版本) lD 生成;False 指定 Visual Studio 2010 lD 生成。 |
4 | Description | Specifies a free-form description for an installer. | 描述 | 指定安裝程序的說明(自由格式) |
5 | Detect Newer Installed Version | Specifies whether to check for newer versions of an application during installation. | 檢測較新的安裝版本 | 指定是否在安裝過程中檢查應(yīng)用程序的較新版本。 |
6 | Install All users | Specifies whether the package is installed for all users or only the installing user. | 所有用戶均可安裝 | 指定是為所有用戶安裝包還是僅為安裝用戶安裝包。 |
7 | Keywords | Specifies keywords used to search for an installer. | 關(guān)鍵字 | 指定用于搜索安裝程序的關(guān)鍵字。 |
8 | Localization | Specifies the locale for string resources and the run-time user interface. | 地方化 | 指定字符串資源的區(qū)域設(shè)置和運(yùn)行時用戶界面。 |
9 | Manufacturer | Specifies the name of the manufacturer of an application or component. | 制造商 | 指定應(yīng)用程序或組件的制造商的名稱。 |
10 | ManufacturerUrl | Specifies a URL for a Web site containing information about the manufacturer application or component . | 制造商網(wǎng)址 | 指定包含制造商相關(guān)信息的網(wǎng)站的 URL應(yīng)用程序或組件。 |
11 | Post Build Event | Specifies any commands to execute after the build ends. | 后期構(gòu)建事件 | 指定要在生成結(jié)束后執(zhí)行的任何命令。 |
12 | Pre Build Event | Specifies any commands to execute before the build starts. | 預(yù)構(gòu)建事件 | 指定在生成開始之前要執(zhí)行的任何命令。 |
13 | Product code | Specifies a unique identifier for an application. | 產(chǎn)品代碼 | 指定應(yīng)用程序的唯一標(biāo)識符。 |
14 | Product Name | Specifies a public name that describes an application or component. | 產(chǎn)品名稱 | 指定描述應(yīng)用程序或組件的公共名稱。 |
15 | Remove Previous Versions | Specifies whether an installer will remove previous versions of an application during installation. | 刪除以前的版本 | 指定安裝程序是否在安裝過程中刪除應(yīng)用程序的早期版本。 |
16 | Run Post Build Event | Specifies the condition under which the post-build event runs. | 運(yùn)行生成后事件 | 指定運(yùn)行后期生成事件的條件。 |
17 | Search Path | Specifies the path that is used to search for assemblies, files, or merge modules on the development computer. | 搜索路徑 | 指定用于在開發(fā)計(jì)算機(jī)上搜索程序集、文件或合并模塊的路徑。 |
18 | Subject | Specifies additional information descrioing an application or component. | 主題 | 指定描述應(yīng)用程序或組件的其他信息。 |
19 | Support Phone | Specifies a phone number for support information for an application or component. | 支持電話 | 指定應(yīng)用程序或組件的支持信息的電話號碼。 |
20 | Support Url | Specifies a URL for a Web site containing support information for an application or component. | 支持網(wǎng)址 | 指定包含應(yīng)用程序或組件支持信息的網(wǎng)站的 URL 。 |
21 | Target Platform | Specifies the target platform of the installer. | 目標(biāo)平臺 | 指定安裝程序的目標(biāo)平臺。 |
22 | Title | Specifies the title of an installer. | 標(biāo)題 | 指定安裝程序的標(biāo)題。 |
23 | Upgrade Code | Specifies a shared identifier that represents multiple versions of an application. | 升級代碼 | 指定表示應(yīng)用程序的多個版本的共享標(biāo)識符。 |
24 | Version | Specifies the version number of an installer, merge module, or .cab file. | 版本 | 指定安裝程序、合并模塊或.cab文件的版本號。 |
到了這里,關(guān)于c# 項(xiàng)目文件 打包成exe安裝包 (vs2015)的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!