2013-03-29 32 views
3

我對Sayed Hashimi和SlowCheetah公司所做的快速步驟和了不起的工作感到困惑,特別是SlowCheetah是否能夠在Build上轉換文件,而不僅僅是打包和發佈。SlowCheetah變換爲非網頁app.config

我已經安裝了SlowCheetah並且能夠自動生成控制檯應用程序的app.config的生成配置實例我正在與開發團隊一起部署。在構建上,在$(ProjectDir)\ obj \ x86 \ $(BuildConfig)目錄下創建一個新的「SlowCheetah」目錄。例如,obj \ x86 \ STAGE \ SlowCheetah目錄包含一個app.config文件,其轉換完成,如右鍵單擊STAGE轉換並選擇「View Transforms」時指示的那樣。但是,\ bin \ $(BuildConfig)目錄包含未轉換的app.config文件以及每個$(BuildConfig)轉換的所有模板,而不是替換$(BuildConfig)中的app.config文件。 bin \ x86 \ STAGE目錄與SlowCheetah中的目錄。

構建完成,沒有錯誤。

這是預期的操作還是仍然不能正常工作?

@ sayed-ibrahim-hashimi每個$(配置)都有一個轉換。在Visual Studio中查看時,轉換將正確顯示,並在\ obj目錄樹下的\ slowcheetah目錄中正確轉換。變換示例如下:

<?xml version="1.0" encoding="utf-8" ?> 
<!-- For more information on using transformations see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. --> 
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform 
<connectionStrings> 
<add name="Portal" connectionString="Data Source=transformtestserver.domain.local;Initial Catalog=TestDB;User Id=TestUser;Password=testpw1;" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> 
<add name="DictionaryDatabase" connectionString="Data Source=transformtestserver.domain.local;Initial Catalog=TestDB;User Id=TestUser;Password=testpw2;" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> 
<add name="LoggingDatabase" connectionString="Data Source=transformtestserver.domain.local;Initial Catalog=TestDB;User Id=TestUser;Password=testpw3;" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>  
</connectionStrings> 
</configuration> 

問題可能與Nuget /解決方案配置有關。我正在使用的項目是一個非常大的解決方案的一部分。我很難安裝並運行SlowCheetah - 一度發現Nuget表示SlowCheetah已安裝,但解決方案包目錄中不包含SlowCheetah。

我在TeamCity中設置了一個解決方法,以從\ obj目錄獲取已轉換的app.config文件,但真的想解決問題,因此我可以將SC部署到完整的開發組。有沒有我們可以看到的詳細日誌可能會指出細節?

+0

App.config應該在構建時進行轉換。你能在這裏提供更具體的repro步驟嗎?你可以嘗試插入轉換來查看源文件是否被修改? –

+0

答覆部分沒有提供足夠的空間給出詳細的答案,對於您的問題的詳細回覆以及轉換示例附加到原始帖子後面,以@ sayed-ibrahim-hashimi – EHuggins

+0

@http://stackoverflow.com/users開頭/ 105999/sayed-ibrahim-hashimi我在VS2010中打開了診斷輸出,並看到app.config正在轉換並保存爲application.exe.config - 它包含正確轉換的web。$(Condition).config文件。我查了一下exe.config文件的細節,看到這是Windows可執行文件的正確行爲。我正在尋找一個app.config文件。看起來我是在浪費你的時間 - 感謝你的迴應,並撰寫出色的應用程序和書籍。你的MSBUILD 2nd Ed。由於某種原因每週最常使用。 – EHuggins

回答

3

我面臨同樣的問題。

VS本地編譯效果很好, 但是build build(TeamCity)轉換魔術沒有發生!

我發現了有關XML元素的位置,該凸出文件

<PropertyGroup Label="SlowCheetah"> 
    <SlowCheetahToolsPath>$([System.IO.Path]::GetFullPath($(MSBuildProjectDirectory)\..\packages\SlowCheetah.2.5.10.3\tools\))</SlowCheetahToolsPath> 
    <SlowCheetah_EnableImportFromNuGet Condition=" '$(SC_EnableImportFromNuGet)'=='' ">true</SlowCheetah_EnableImportFromNuGet> 
    <SlowCheetah_NuGetImportPath Condition=" '$(SlowCheetah_NuGetImportPath)'=='' ">$([System.IO.Path]::GetFullPath($(MSBuildProjectDirectory)\Properties\SlowCheetah\SlowCheetah.Transforms.targets))</SlowCheetah_NuGetImportPath> 
    <SlowCheetahTargets Condition=" '$(SlowCheetah_EnableImportFromNuGet)'=='true' and Exists('$(SlowCheetah_NuGetImportPath)') ">$(SlowCheetah_NuGetImportPath)</SlowCheetahTargets> 
    </PropertyGroup> 

我已經注意到了該解決方案是,當PropertyGroup首先是ItemGroup`s ellements MsBuild.exe最後轉換

+0

加票,不是因爲這是我的答案,而是指向正確的地方。我必須更新我的''元素中的路徑以匹配SlowCheetah文件的位置。構建服務器上的位置與SlowCheetah安裝時我的計算機上的默認位置不同。 – Zarepheth

0

尋找重複的SlowCheetahTargets部分 - 我有一箇舊版本和一個較新的版本,而較舊的版本指向nuget軟件包目錄中不再存在的位置。

刪除舊的/重複的SlowCheetahTargets部分的整個屬性組,並且應該修復它。

+0

看到這個主題(特別是關於Properties-> SlowCheetah-> SlowCheetah.Transforms.targets的最新帖子http://forums.asp.net/t/1697459.aspx –