項目場景:
wpf core 怎麼打包安裝包
問題描述:
這個問題困擾了我很久 用過微軟自帶的

失敗
用過wix toolset 失敗
error CNDL0044 : The Class element’s ForeignServer or Server attribute was not found; one of these is required.
C:\Program Files (x86)\WiX Toolset v3.11\bin>light.exe -ext WixUIExtension Pack2MSI.wixobj
light.exe : error LGHT0103 : The system cannot find the file ‘Pack2MSI.wixobj’ with type ‘Source’.
國外論壇
DevExpress.更新問題
說是 少添加了 -sreg -scom
當時在家 遠端弄 還是失敗 懶得整了
heat.exe : error HEAT0001 : 對路徑“C:\Program Files (x86)\WiX Toolset v3.11\bin\myAppad.wxs”的通路被拒絕。
Exception Type: System.UnauthorizedAccessException
Stack Trace:
在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
在 System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
在 System.IO.FileStream…ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
在 System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
在 System.IO.StreamWriter…ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
在 System.IO.StreamWriter…ctor(String path, Boolean append, Encoding encoding)
在 Microsoft.Tools.WindowsInstallerXml.Tools.Heat.Run(String[] args)
很多微軟推薦的都用了 生成uwp等
後來問群友 推薦 單一檔案 但是調用不了資源檔案 圖檔或者檔案的
但是算是給我打開大門,我既然能釋出 釋出的檔案夾也能運作 打包和微軟有啥關系。。沒關系啊 跟檔案夾有關系啊
原因分析:
是以抛開所有 打封包件夾才對
解決方案:
首先是釋出
選擇獨立
把這些資源檔案 放在發個釋出的檔案夾裡 這些資源通路 代碼
```csharp
string ptp = Directory.GetCurrentDirectory();
ptp =ptp+"/TXT/模闆.xlsx";
這塊就是通路 bin\Debug\netcoreapp3.1 資源代碼
打開釋出後檔案夾中的 exe 能完美運作 下一步打包
這裡用到了
NSIS和 HM NIS Edit
和
打開HM NIS Edit
打開檔案
建立腳本向導
下一步
設定好這些名稱東西
選擇簡體中文 當然你有别的語言需求再說
選擇授權檔案 自己建立txt 加點文字就行
删除掉這個exe
點選樹狀圖 然後 添加你釋出的那個檔案夾
下一步
繼續下一步
點選完成 儲存好檔案
如果這裡報錯 沒關系 删除掉就行
運作完
到這裡找到安裝包就行
完美
其實還有很多 打包軟體 而且有些很傻瓜 很友善。比wix 強多了