【问题标题】:EntryPointNotFoundException when attempting to use TransformXml in custom build activity尝试在自定义构建活动中使用 TransformXml 时出现 EntryPointNotFoundException
【发布时间】: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


    【解决方案1】:

    似乎我引用了我需要的不正确版本的 dll;它编译得很好,但不能正常运行。

    我没有按照其他站点的建议通过 C:\ 搜索所需的 dll,而是在 Reference Manager > Assemblies > Framework 中找到了我需要的四个 Microsoft 程序集

    Microsoft.Build.Framework

    Microsoft.Build.Utilities.v4.0

    Microsoft.TeamFoundation.Build.Client

    Microsoft.TeamFoundation.Build.Workflow

    这最终解决了我的问题,现在正在根据需要转换配置文件

    【讨论】:

      猜你喜欢
      • 2018-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-15
      • 1970-01-01
      • 1970-01-01
      • 2021-04-12
      • 1970-01-01
      相关资源
      最近更新 更多