我遇到了問題,試圖讓我的構建控制器/代理從我的構建過程模板中使用的引用中選擇自定義程序集。TFS不加載自定義程序集
我讀過關於這個問題的廣泛跨越幾個博客,不幸的是,我一直無法來解決這個問題:
]
我可以確認以下內容:
TFS 2012沒有更新Visual Studio 2013更新1(創建 活動並升級構建過程模板)
一個生成控制器與多發劑
的TFS大會和源控制
正確的路徑設置與服務構建控制器內內檢查重新啓動:
自定義活動在遵循指南li時在模板中正確解析在這些博客使用的網元:
我可以查看生成過程模板的XAML中的參考,它看起來很好,沒有驗證錯誤,我的代碼活動似乎正確執行。下面
代碼:
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Activities;
using System.Text.RegularExpressions;
using Microsoft.TeamFoundation.Build.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
namespace FireWatch.TFS
{
[BuildActivity(HostEnvironmentOption.Agent)]
public sealed class AssemblyUpdater : CodeActivity
{
#region Static Methods
#endregion
#region Property Variables
#endregion
#region Constants and Read-Onlys
private const string ASSEMBLY_VERSION_REG_EX = @"\(""\d+\.\d+\.\d+\.\d+""\)";
private const string ATTRIBUTE_REG_EX = "AssemblyVersion";
#endregion
#region Accessors
[RequiredArgument]
public InArgument<int> Major { get; set; }
[RequiredArgument]
public InArgument<int> Minor { get; set; }
[RequiredArgument]
public InArgument<int> Build { get; set; }
[RequiredArgument]
public InArgument<Workspace> Workspace { get; set; }
#endregion
#region Encapsulation
private void UpdateAssemblyInfo(IEnumerable<string> assemblyInfos, int major, int minor, int build)
{
foreach (string myAssemblyInfo in assemblyInfos)
{
string myFileText = File.Exists(myAssemblyInfo) ? File.ReadAllText(myAssemblyInfo) : string.Empty;
if (myFileText != string.Empty)
{
Regex myRegex = new Regex(ATTRIBUTE_REG_EX + ASSEMBLY_VERSION_REG_EX);
Match myMatch = myRegex.Match(myFileText);
if (myMatch.Success)
{
string myVersionNumber = myMatch.Value.Substring(ATTRIBUTE_REG_EX.Length + 2,
myMatch.Value.Length - ATTRIBUTE_REG_EX.Length - 4);
Version myCurrentVersion = new Version(myVersionNumber);
Version myNewVersion = new Version(major, minor, build, (myCurrentVersion.Revision + 1));
string myUpdatedAssemblyText = myRegex.Replace(myFileText, ATTRIBUTE_REG_EX + "(\"" + myNewVersion + "\")");
File.WriteAllText(myAssemblyInfo, myUpdatedAssemblyText);
}
}
}
}
private void CheckOut(Workspace workspace, IList<string> assemblyInfos)
{
if (workspace != null && assemblyInfos != null && assemblyInfos.Any())
{
workspace.PendEdit(assemblyInfos.ToArray());
}
}
private IEnumerable<string> GetRelevantAssemblyInfos(Workspace workspace)
{
IList<string> myReturn = new List<string>();
PendingChange[] myPendingChanges = workspace.GetPendingChanges();
foreach (PendingChange myPendingChange in myPendingChanges)
{
string myPath = AssemblyInfoPresent(myPendingChange);
if (!string.IsNullOrEmpty(myPath))
{
myReturn.Add(myPath);
}
}
return myReturn;
}
private string AssemblyInfoPresent(PendingChange pendingChange)
{
string myReturn = string.Empty;
if (pendingChange != null)
{
string myParentDirectory = pendingChange.LocalItem;
string myParentLevelAssemblyInfo = myParentDirectory + @"\AssemblyInfo.cs";
string myPropertiesDirectory = pendingChange.LocalItem + @"\Properties";
string myPropertiesLevelAssemblyInfo = myParentDirectory + @"\Properties\AssemblyInfo.cs";
if (Directory.Exists(myPropertiesDirectory) && File.Exists(myPropertiesLevelAssemblyInfo))
{
myReturn = myPropertiesLevelAssemblyInfo;
}
else if (Directory.Exists(myParentDirectory) && File.Exists(myParentLevelAssemblyInfo))
{
myReturn = myParentLevelAssemblyInfo;
}
}
return myReturn;
}
#endregion
#region CodeActivity Members
protected override void Execute(CodeActivityContext context)
{
int myMajor = context.GetValue(this.Major);
int myMinor = context.GetValue(this.Minor);
int myBuild = context.GetValue(this.Build);
Workspace myWorkspace = context.GetValue(this.Workspace);
IList<string> myAssemblyInfos = GetRelevantAssemblyInfos(myWorkspace).Distinct().ToList();
if (myAssemblyInfos.Any())
{
CheckOut(myWorkspace, myAssemblyInfos);
UpdateAssemblyInfo(myAssemblyInfos, myMajor, myMinor, myBuild);
}
}
#endregion
}
}
我們的構建控制器每晚重新啓動,但構建代理尚未重新啓動。我會期待今晚重新啓動我的構建代理,並希望這可以解決問題。謝謝你的幫助,謝謝。 – Slavvy 2014-09-02 10:11:07
不幸的是,這並沒有解決這個問題。我很感激幫助,你有沒有可靠的教程展示如何擴展我可以嘗試的代碼活動?只是因爲我有可能錯過了一步。我相當有信心,雖然我沒有。 – Slavvy 2014-09-03 07:49:57
您的dll是否顯示在這些緩存文件夾中? – 2014-09-03 07:59:16