【发布时间】:2014-06-28 04:57:30
【问题描述】:
在设置 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
}
【问题讨论】:
标签: tfsbuild web-config-transform