关于团队构建和构建网站,自定义代码活动问题

时间:2010-11-19 16:54:27

标签: msbuild web build tfs2010 team-build

我正在尝试使用Team Build 2010发布网站,但我没有看到任何简单的选项。所以我尝试创建一个自定义活动,用我的参数调用代理中的进程(“aspnet_compiler.exe”)并发布我的站点。

我可以删除文件夹,创建文件夹,编译和构建项目......

但是当我调用它时,这个过程并没有在代理上启动......问题是什么?

    protected override void Execute(CodeActivityContext context)
    {
        // Obtain the runtime value of the Text input argument
        // string text = context.GetValue(this.Text);
        Process proc = new Process();
        proc.EnableRaisingEvents = true;
        proc.StartInfo.WorkingDirectory = @"C:\Windows\Microsoft.NET\Framework\v2.0.50727";
        proc.StartInfo.FileName = "aspnet_compiler.exe";
        proc.StartInfo.Arguments = "-p "+context.GetValue(this.SourcesDirectory) +
               " -v / " + PublishDirectory;
        proc.Start();
        proc.WaitForExit();

        while (!proc.HasExited)
        {
        }

        context.SetValue(Result,proc.StandardOutput.ReadToEnd());
    }

有没有其他方法来构建/发布网站?我的代码出了什么问题?

1 个答案:

答案 0 :(得分:1)

每次TFS构建项目/解决方案时,它都会自动发布Web项目/站点并将它们放在名为_PublishedWebsites的文件夹中。你可以轻松使用它。

此外,如果您需要将此文件夹复制/移动到其他位置,或者即使您需要对其他文件/文件夹执行此操作,也可以使用CopyDirectoryDeleteDirectory和其他Team Foundation构建活动。如果您仍需要在构建过程中运行某些内容,则可以使用InvokeProcess构建活动,而不是创建自己的构建活动。

相关问题