2011-05-10 53 views
6

我想在我的項目中使用這種簡單的方案:從TFS生成文件的VS2010 T4自動檢出失敗

Item.cs - >這包含了簡單的實體屬性的C#部分類。 它也設置屬性「自定義工具:T4ScriptFileGenerator」,所以它附加「分組」文件Item.tt它。 Wich在其途中生成Item.generated.cs,分組爲Item.tt。 所以導致分組樹在解決方案資源管理:

Item.cs 
˪Item.tt 
˪Item.generated.cs 

下面你可以看到它的外觀在.csproj的文件。

整個項目連接到TFS 2010工作區。

的問題是:

當我編輯Item.cs,T4引擎重建Item.generated.cs文件,但不從TFS簽出它。它僅自動檢出「分組」文件的前兩個級別 - Item.cs及其相關文件Item.ttItem.generated.cs已更新,但是簡單覆蓋,而不簽出。

如果我編輯Item.tt文件,或直接按「運行自定義工具」就可以了 - 又兩個文件被檢查出:Item.tt及其相關Item.generated.cs 這是奇怪,因爲力量我們在編輯實體類文件後在每個* .tt文件上手動「運行自定義工具」,以確保TFS中沒有任何東西丟失。

問:有沒有什麼辦法,迫使它Item.cs編輯主時檢查出的DependentUpon文件整個樹?

這裏是如何看起來.csproj的文件來源:

<Compile Include="Entities\Item.cs"> 
    <Generator>T4ScriptFileGenerator</Generator> 
    <LastGenOutput>Item.tt</LastGenOutput> 
</Compile> 
<None Include="Entities\Item.tt"> 
    <Generator>TextTemplatingFileGenerator</Generator> 
    <AutoGen>True</AutoGen> 
    <DesignTime>True</DesignTime> 
    <DependentUpon>Item.cs</DependentUpon> 
    <LastGenOutput>Item.codegen.cs</LastGenOutput> 
</None> 
<Compile Include="Entities\Item.codegen.cs"> 
    <AutoGen>True</AutoGen> 
    <DesignTime>True</DesignTime> 
    <DependentUpon>Item.tt</DependentUpon> 
</Compile> 
+0

我在VS2010 SP1中沒有看到您的解決方案的小再現問題。我沒有沒有SP1的2010版,所以它可能是一個項目系統修復的補丁包或更新版本的T4Toolbox,但它適用於我。你還在看到這個問題嗎? 另請參閱下面的簡單答案,我的解決方法。 – GarethJ 2011-12-21 02:59:46

回答

0

這不是很優雅,但你總是可以得到VS通過點擊「轉換所有模板」改造的解決方案的所有模板按鈕在解決方案資源管理器的頂部。

看到我的筆記在原始問題上,至少在VS2010 SP1中,這似乎工作,給出了確切的示例項目文件片段。

0
/// <summary> 
/// (T4 template code to checkout a file path if necessary) 
/// </summary> 
/// <param name="fileName">The file name.</param> 
private void CheckoutFileIfRequired(String fileName) 
{ 
    var sc = this.dte.SourceControl; 
    if (sc != null && sc.IsItemUnderSCC(fileName) && !sc.IsItemCheckedOut(fileName)) 
      checkOutAction.EndInvoke(checkOutAction.BeginInvoke(fileName, null, null)); 
}