Skip to content
Rain Hu's Workspace
Go back

[DXP] 使用 Visual Studio 對 Spotfire 開發進行環境設置

Rain Hu

在 Visual Studio 中創建 Extension

  1. 在 Visual Studio 中,選擇 [Tools] > [Options],並在 [Projects and Solutions] > [Locations] 下,將 [User project templates location] 設定為 Spotfire SDK 中 [Templates] 資料夾的路徑。 pic1
  2. 在 Visual Studio 中,選擇 [File] > [New] > [Project],然後選擇 [TIBCO Spotfire Extension_VS][TIBCO Spotfire Extension Net6_VS] 範本。請注意,TIBCO Spotfire Extension Net6_VS 範本是一個 SDK-style 專案,它允許同時為多個平台進行構建。這是本範例中使用的範本。為了使預定義的後置構建步驟正常工作,
  1. 透過選擇 [Build] > [Build Solution] 來編譯新建立的專案。這將會產生一個新的子資料夾 MyExtensions\Build,其中會存放所有建置產物。
    • 編譯後的二進制文件與 SDK 二進制文件會儲存在 Build\bin\ 中。例如,Build\bin\net6.0Build\bin\AnyCPU\Debug
    • 一個或多個 Spotfire 套件檔案 (.spk) 儲存在 Build 資料夾中。
    • 套件檔案的未打包版本儲存在 Build\Modules\<Extension-name>_<Version number>中。例如,TIBCO Spotfire_Extension_Net6_VS-Windows_1.0.6320.3907。這樣與下載的 Spotfire 的擴充方式一致,更易於 debug。
  2. 為了能夠除錯擴充功能,需在 Visual Studio 中手動進行以下配置:
    • Solution Explorer 中選擇擴充功能專案。
    • 選擇 [View] > [Property Pages]
    • 在 Debug 頁面上,點擊 [Open debug launch profiles UI],然後在 [Launch Profiles] 對話框中執行以下操作:
      • 點擊 [Create a new profile],並選擇 [Executable]
      • [Executable] 下,指向電腦中的 Spotfire.Dxp.exe。它可以是安裝的版本、某些中間測試版本或類似版本。例如,C:\Users\{username}\AppData\Local\TIBCO\Spotfire\12.0.0\Spotfire.Dxp.exe
      • 在 CLI 下,輸入 /loadallmodules /addmodulefolder:<SDK 中模組資料夾的路徑>,舉例:
      /loadallmodules /addmodulefolder:C:\SpotfireSDK\SDK\MyExtensions\Build\Modules`。
  3. 為了驗證擴展功能已經載入,請在 Visual Studio 中選擇新的 Debug 檔案,並運行它以確保 Spotfire 已啟動。 pic3
  4. 在 Spotfire 中,請前往 [Help] > [Support Diagnostics and Logging],向下捲動已載入檔案的清單,以確認擴充功能已載入。 pic4
  5. 使用標準管理使用者介面 [Deployments & Packages],將儲存在 Build 資料夾中的套件檔案部署到 Spotfire 伺服器。

自訂環境和進階資訊

可以透過編輯 post-build command 來配置 Visual Studio 環境。

  1. Solution Explorer 中選擇擴充的專案。
  2. 選擇 [View] > [Property Pages]
  3. [Build Event] 頁面上,查看 [Post-build event command line] pic5
  4. 根據需求修改後置命令,後置命令會執行位於專案資料夾中的 PostBuildEvent.bat 檔案。TIBCO Spotfire Extension_VS.zip 模板的後置檔案需要四個參數,TIBCO Spotfire Extension Net6 VS.zip 則需要六個參數。由 Visual Studio Macro 來定義,分別為:
    • $(ProjectDir):專案資料夾的完整路徑。
    • $(ProjectName):項目的名稱。
    • $(TargetDir):創建 Packge 應儲存的資料夾。
    • $(Configuration):建置設定(Debug/Release)。
    • $(TargetFramework):目標框架。("net48" for Window,"net6.0" for Linux)
    • $(AdditionBinaryFolders):一個以分號分隔的額外添加的二進制文件夾列表,用於 refpath 參數。

PostBuildEvent.bat 檔案後的後置命令為:

"%~1..\..\..\Package Builder\Spotfire.Dxp.PackageBuilder-Console.exe" /pkdesc:"%~1%~2.pkdesc" /target:"%~1..\..\build\%~2.spk" /basefolder:"%~3..\%~4" /refpath:"%~3..\%~4;%~1..\..\..\Binaries" /saveunpackedmodule /unpackedmodulefolder:"%~1..\..\Build\Modules" /automaticpackageversionnumber


Share this post on:

Previous
[DXP] 在 spotfire 中創建自定義任務
Next
[CS] Sample cost for performance test