首页 > 解决方案 > .NET / Visual Studio 从代码发布 WebApp(自动化)

问题描述

我有一个控制台应用程序设置,您可以在其中传递项目目录以及您想要从 git 获得的分支,它将检查出来。签出后,我希望我的代码自动从该应用程序目录中的发布配置文件发布应用程序。

这背后的原因是有时我需要将某个票证/分支推送到我们的测试站点,它是一个皮塔饼,以停止我正在做的检查分支的操作​​,在 Visual Studio 中打开它并完成发布过程。

我很困惑从哪里开始,因为我在谷歌上没有找到任何有用的东西。在 C# 代码中自动化发布过程的任何帮助都会很有用。

伪代码

        static void Main(string[] args)
        {
            string directory = args[0];
            string branch = args[1];

            using (PowerShell powershell = PowerShell.Create())
            {
                
                powershell.AddScript($"cd {directory}");

                powershell.AddScript(@"git checkout " + branch);

                Collection<PSObject> results = powershell.Invoke();

            }

           // Go to the directory and publish the webapp from publish profile
        }

标签: c#

解决方案


推荐阅读