当前位置: 首页>>代码示例>>C#>>正文


C# Report.removeIfExists方法代码示例

本文整理汇总了C#中Report.removeIfExists方法的典型用法代码示例。如果您正苦于以下问题:C# Report.removeIfExists方法的具体用法?C# Report.removeIfExists怎么用?C# Report.removeIfExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Report的用法示例。


在下文中一共展示了Report.removeIfExists方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            // set these variables before runing the tool
            string project_name = "";
            string project_path = @"";
            string sandbox_path = @"";
            string oldRootSol = @"";
            string testLocation = @"";

            //define script paths
            string git_script = @"G:\new_demo\ApiMonkey\C#\nApiMonkey\nApiMonkey\scripts\gitcmd.sh";
            string build_script = @"G:\new_demo\ApiMonkey\C#\nApiMonkey\nApiMonkey\scripts\build.bat";
            string copy_script = @"G:\new_demo\ApiMonkey\C#\nApiMonkey\nApiMonkey\scripts\script.bat";
            //end of variables

            //Clone project from git. Can be skipped and done manually as well.
            System.Diagnostics.Process.Start(git_script, project_path).WaitForExit();

            Report repo = new Report();
            repo.ReportLocation = project_path;
            repo.ReportName = project_name + "Report.md";
            repo.removeIfExists();

            //Run msbuild and test executino on original project. and write the results to the report.
            System.Diagnostics.Process.Start(build_script, oldRootSol + " " + project_name + ".sln " + testLocation).WaitForExit();
            TRXReader tr = new TRXReader();
            repo.writeOriginalReport(oldRootSol, tr);

            PackageConfigReader reader = new PackageConfigReader();
            //Read the entire project for packages.config files and build a dictionary with packages and the projects list which reference them.
            List<string> packageFilePaths = reader.readAllConfigs(oldRootSol);
            Dictionary<PackageElement, List<string>> dictionary = reader.readConfig(packageFilePaths, oldRootSol);
            List<PackageElement> oldlist = new List<PackageElement>(dictionary.Keys);
            //Check if newer versions are available for the packages.
            List<PackageElement> update = checkUpdate(oldlist);
            StringBuilder testResult = new StringBuilder();
            if (update == null) Console.Write("No updates found");
            else
            {
                //Go through all packages where update is available and create sandboxes for each of them
                foreach (PackageElement e in update)
                {
                    bool success=true;
                    List<string> paths = dictionary[e];
                    string newRootSol = sandbox_path + @"\" + project_name + @"_" + e.Packageid.Substring(0, e.Packageid.Length / 2 + 1) + e.Version.ToNormalizedString();
                    //string newProjectPath = newRootSol + @"\" + project_name;
                    Directory.CreateDirectory(newRootSol);
                    System.Diagnostics.Process.Start(copy_script, oldRootSol + " " + newRootSol + " " + project_name + ".sln ").WaitForExit();
                    //Update references to the new version for all projects which refer to it
                    foreach (string projectPath in paths)
                    {
                        Console.WriteLine("Updating " + projectPath);
                        PackageConfigReader newConfReader = new PackageConfigReader();
                        string newPathToPackages = newRootSol + projectPath + @"packages.config";
                        string newProjectPath = newRootSol + projectPath;
                        string project = Directory.EnumerateFiles(newProjectPath, "*.csproj?").First();
                        UpdateCommand updateCmd = new UpdateCommand();
                        bool update_success=updateCmd.Execute(e.Packageid, project, e.Version, newRootSol + @"\packages");
                        if (update_success == false)
                        {
                            success = false;
                            break;
                        }
                            newConfReader.writeToConfig(newPathToPackages, e.Packageid, e.Version);
                    }
                    if (success)
                    {
                        //If uodate is successful, run the build and write results to final report.
                        System.Diagnostics.Process.Start(@"G:\new_demo\ApiMonkey\C#\nApiMonkey\nApiMonkey\scripts\build.bat", newRootSol + " " + project_name + ".sln " + testLocation).WaitForExit();
                        tr = new TRXReader();
                        testResult = tr.read(newRootSol + @"\testResults.trx");
                        repo.writeBuildReport(newRootSol, e.Packageid, e.Version, testResult,true);
                    }
                    else
                        repo.writeBuildReport(newRootSol, e.Packageid, e.Version, testResult, false);
                }

            }

            Console.ReadKey();
        }
开发者ID:alt-code,项目名称:ApiMonkey,代码行数:81,代码来源:Program.cs


注:本文中的Report.removeIfExists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。