在设置TFS 2013以构建和部署开发和测试系统的站点和服务的过程中,我遇到了this StackOverflow answer来创建自定义构建活动以转换Web.config文件。我已经将它添加到构建过程模板中,TFS在构建/部署过程中调用它,但是当调用transformation.Execute()时,我收到了
Microsoft.Build.Utilities.v4.0.dll中出现未处理的“System.EntryPointNotFoundException”类型异常
其他信息:未找到入口点。
我创建了一个快速控制台应用程序来直接调用自定义活动,我也得到了在本地计算机上抛出的相同异常。
作为参考,这是我上面链接的答案的自定义构建活动
/// <summary>
/// Transforms configuration files using TransformXml
/// </summary>
[BuildActivity(HostEnvironmentOption.All)]
public sealed class WebConfigTransform : CodeActivity
{
#region Public Properties
/// <summary>
/// The binaries folder
/// </summary>
[RequiredArgument]
public InArgument<string> BinariesLocation { get; set; }
#endregion
#region Overrides of CodeActivity
/// <summary>
/// When implemented in a derived class, performs the execution of the activity.
/// </summary>
/// <param name="context">The execution context under which the activity executes.</param>
protected override void Execute(CodeActivityContext context)
{
var binariesFolder = context.GetValue(BinariesLocation);
foreach (var sourceFolder in Directory.GetDirectories(Path.Combine(binariesFolder, "_PublishedWebsites")))
{
var sourceFile = Path.Combine(sourceFolder, "Web.config");
if (File.Exists(sourceFile))
{
var filesToTransform = Directory.GetFiles(sourceFolder, "Web.*.config");
foreach (var fileToTransform in filesToTransform)
{
var tempSourceFile = Path.GetTempFileName();
var tempTransformFile = Path.GetTempFileName();
File.Copy(sourceFile, tempSourceFile, true);
File.Copy(fileToTransform, tempTransformFile, true);
var transformation = new TransformXml
{
BuildEngine = new BuildEngineStub(),
Source = tempSourceFile,
Transform = tempTransformFile,
Destination = fileToTransform
};
transformation.Execute();
}
}
}
}
#endregion
}
public class BuildEngineStub : IBuildEngine
{
#region IBuildEngine Members
public bool BuildProjectFile(string projectFileName, string[] targetNames,
IDictionary globalProperties,
IDictionary targetOutputs)
{
throw new NotImplementedException();
}
public int ColumnNumberOfTaskNode
{
get { return 0; }
}
public bool ContinueOnError
{
get { return false; }
}
public int LineNumberOfTaskNode
{
get { return 0; }
}
public string ProjectFileOfTaskNode
{
get { return ""; }
}
public void LogCustomEvent(CustomBuildEventArgs e)
{
Console.WriteLine("Custom: {0}", e.Message);
}
public void LogErrorEvent(BuildErrorEventArgs e)
{
Console.WriteLine("Error: {0}", e.Message);
}
public void LogMessageEvent(BuildMessageEventArgs e)
{
Console.WriteLine("Message: {0}", e.Message);
}
public void LogWarningEvent(BuildWarningEventArgs e)
{
Console.WriteLine("Warning: {0}", e.Message);
}
#endregion
}
答案 0 :(得分:0)
似乎我提到了我需要的不正确版本的dll;它编译得很好但不能正常运行。
我没有在C:\中搜索以查找其他网站上建议的必要dll,而是在Reference Manager中找到了我需要的四个Microsoft程序集&gt;组件&gt;框架
Microsoft.Build.Framework
Microsoft.Build.Utilities.v4.0
Microsoft.TeamFoundation.Build.Client
Microsoft.TeamFoundation.Build.Workflow
这最终修复了我的问题,配置文件现在正在根据需要进行转换