Exemplo n.º 1
0
        /// <summary>
        /// Executes the specified SQL script file.
        /// </summary>
        /// <param name="scriptFileName">Name of the script file.</param>
        /// <param name="userName">Name of the database user.</param>
        /// <param name="password">The database user's password.</param>
        /// <param name="useDatabase">The database to run the script under. If <c>null</c>, the script will run under
        /// the default database.</param>
        /// <returns>The same instance of this <see cref="BuildRunner"/>.</returns>
        public TRunner ExecuteSqlScriptFile(
            string scriptFileName,
            string userName,
            string password,
            string useDatabase)
        {
            ProgramRunner
            .AddArgument("-U")
            .AddArgument(userName)
            .AddArgument("-P")
            .AddArgument(password)
            .AddArgument("-i")
            .AddArgument(scriptFileName)
            .AddArgument("-r1")
            .AddArgument("-m-1");

            if (useDatabase != null)
            {
                ProgramRunner
                .AddArgument("-d")
                .AddArgument(useDatabase);
            }

            ProgramRunner.Run(@"C:\Program Files\Microsoft SQL Server\90\Tools\Binn\osql.exe", false);

            return(ReturnThisTRunner());
        }
Exemplo n.º 2
0
        public TRunner SourceMonitor()
        {
            string sourceMonitorProjectFile = MakePathFromRootDir(ProductId + ".smp");

            AssertFileExists("SourceMonitor project file", sourceMonitorProjectFile);

            string copyOfProjectFile = MakePathFromRootDir(ProductId + ".copy.smp");

            CopyFile(sourceMonitorProjectFile, copyOfProjectFile, true);

            string sourceMonitorCommandFile = MakePathFromRootDir("SourceMonitor.Commands.xml");

            string reportDir             = EnsureBuildLogsTestDirectoryExists();
            string sourceMonitorCommands = ConstructSourceMonitorCommands(
                copyOfProjectFile,
                reportDir);

            File.WriteAllText(
                sourceMonitorCommandFile,
                sourceMonitorCommands);

            ProgramRunner
            .AddArgument("/C")
            .AddArgument(sourceMonitorCommandFile)
            .Run(MakePathFromRootDir(LibDir + @"\SourceMonitor\SourceMonitor.exe"));

            return(ReturnThisTRunner());
        }
Exemplo n.º 3
0
        public TRunner Gendarme(params string[] projectNames)
        {
            string reportDir      = EnsureBuildLogsTestDirectoryExists();
            string reportFileName = string.Format(
                CultureInfo.InvariantCulture,
                "{0}.GendarmeReport.xml",
                ProductId);
            string gendarmeXmlReportFile = Path.Combine(reportDir, reportFileName);

            ProgramRunner
            .AddArgument("--html")
            .AddArgument("{0}.GendarmeReport.html", ProductId)
            .AddArgument("--xml")
            .AddArgument(gendarmeXmlReportFile)
            .AddArgument("--severity")
            .AddArgument("all");

            new List <string>(projectNames).ForEach(
                projectName =>
            {
                string outputPath = GetProjectOutputPath(projectName);
                if (outputPath == null)
                {
                    return;
                }

                VSProjectWithFileInfo projectInfo = (VSProjectWithFileInfo)Solution.FindProjectByName(projectName);

                string projectOutputType       = projectInfo.Project.Properties["OutputType"];
                string projectAssemblyName     = projectInfo.Project.Properties["AssemblyName"];
                string projectAssemblyFileName = string.Format(
                    CultureInfo.InvariantCulture,
                    "{0}.{1}",
                    projectAssemblyName,
                    projectOutputType == "Library" ? "dll" : "exe");

                string projectAssemblyFullPath = Path.Combine(
                    Path.Combine(
                        projectInfo.ProjectDirectoryPath,
                        outputPath),
                    projectAssemblyFileName);

                ProgramRunner.AddArgument(projectAssemblyFullPath);
            });

            string gendarmePath = MakePathFromRootDir(LibDir + @"\Gendarme\gendarme.exe");

            AssertFileExists("Gendarme.exe", gendarmePath);
            ProgramRunner.Run(gendarmePath, true);

            return(ReturnThisTRunner());
        }
Exemplo n.º 4
0
        public DetergentBuildRunner CompileSolution2(string dotNetVersion)
        {
            ScriptExecutionEnvironment.LogTaskStarted("Compiling the solution");
            string msbuildPath = ScriptExecutionEnvironment.GetDotNetFWDir(dotNetVersion);

            ProgramRunner
            .AddArgument(MakePathFromRootDir(ProductId) + ".2010.sln")
            .AddArgument("/p:Configuration={0}", BuildConfiguration)
            .AddArgument("/consoleloggerparameters:NoSummary")
            .Run(Path.Combine(msbuildPath, @"msbuild.exe"));

            ScriptExecutionEnvironment.LogTaskFinished();
            return(this);
        }
Exemplo n.º 5
0
        public DetergentBuildRunner RunTests2(string projectName, bool collectCoverageData)
        {
            Log("Runs tests on '{0}' assembly ({1})", new object[] { projectName, collectCoverageData ? "with coverage" : "without coverage" });
            string buildLogsDir = EnsureBuildLogsTestDirectoryExists();
            VSProjectWithFileInfo testProjectWithFileInfo = (VSProjectWithFileInfo)Solution.FindProjectByName(projectName);
            string projectTargetPath = GetProjectOutputPath(testProjectWithFileInfo.ProjectName);

            projectTargetPath = Path.Combine(testProjectWithFileInfo.ProjectDirectoryPath, projectTargetPath) + testProjectWithFileInfo.ProjectName + ".dll";
            projectTargetPath = Path.GetFullPath(MakePathFromRootDir(projectTargetPath));
            string gallioEchoExePath = MakePathFromRootDir(Path.Combine(LibDir, @"Gallio\bin\Gallio.Echo.exe"));

            try
            {
                //if (collectCoverageData)
                //{
                //    ProgramRunner.AddArgument(Path.Combine(LibDir, @"NCover v1.5.8\CoverLib.dll")).AddArgument("/s").Run("regsvr32");
                //    ProgramRunner.AddArgument(gallioEchoExePath);
                //}
                ProgramRunner
                .AddArgument(projectTargetPath)
                .AddArgument("/runner:NCover")
                .AddArgument("/report-directory:{0}", new object[] { buildLogsDir })
                .AddArgument("/report-name-format:TestResults-{0}", new object[] { TestRuns })
                .AddArgument("/report-type:xml")
                .AddArgument("/verbosity:verbose");
                //if (collectCoverageData)
                //{
                //    ProgramRunner.AddArgument("//x").AddArgument(@"{0}\Coverage-{1}.xml", new object[] { buildLogsDir, TestRuns }).AddArgument("//ea").AddArgument("MbUnit.Framework.TestFixtureAttribute").AddArgument("//w").AddArgument(Path.GetDirectoryName(projectTargetPath)).AddArgument("//v").Run(MakePathFromRootDir(Path.Combine(libDir, @"NCover v1.5.8\NCover.Console.exe")));
                //    CoverageResultsExist = true;
                //}
                //else
                //{
                ProgramRunner.Run(gallioEchoExePath);
                //}
                IncrementTestRunsCounter();
            }
            finally
            {
                //if (collectCoverageData)
                //{
                //    ProgramRunner.AddArgument(Path.Combine(LibDir, @"NCover v1.5.8\CoverLib.dll")).AddArgument("/s").AddArgument("/u").Run("regsvr32");
                //}
            }

            return(this);
        }
Exemplo n.º 6
0
        public TRunner MergeCoverageReports()
        {
            // do this only if there were actual tests run
            if (coverageResultsExist)
            {
                string buildLogsDir = EnsureBuildLogsTestDirectoryExists();
                string ncoverExplorerConfigFileName = MakePathFromRootDir(ProductId) + ".NCoverExplorer.config";

                ProgramRunner
                .AddArgument(Path.Combine(buildLogsDir, "Coverage*.xml"));
                if (File.Exists(ncoverExplorerConfigFileName))
                {
                    ProgramRunner
                    .AddArgument("/c:{0}", ncoverExplorerConfigFileName);
                }
                ProgramRunner
                .AddArgument("/x:{0}", Path.Combine(buildLogsDir, "MergedCoverageReport.xml"))
                .AddArgument("/r:5")
                .AddArgument("/p:{0}", ProductName)
                .Run(Path.Combine(libDir, @"NCoverExplorer-1.3.6.36\NCoverExplorer.Console.exe"));
            }

            return(ReturnThisTRunner());
        }
Exemplo n.º 7
0
        public TRunner FxCop()
        {
            ScriptExecutionEnvironment.LogTaskStarted("Running FxCop analysis");

            string fxProjectPath = MakePathFromRootDir(productId) + ".FxCop";

            AssertFileExists("FxCop project file", fxProjectPath);

            string fxReportPath = EnsureBuildLogsTestDirectoryExists();

            fxReportPath = Path.Combine(fxReportPath, productId);
            fxReportPath = String.Format(
                CultureInfo.InvariantCulture,
                "{0}.FxCopReport.xml",
                fxReportPath);

            ProgramRunner
            .AddArgument(@"/project:{0}", fxProjectPath)
            .AddArgument(@"/out:{0}", fxReportPath)
            .AddArgument(@"/dictionary:CustomDictionary.xml")
            .AddArgument(@"/ignoregeneratedcode");

            string fxCopCmdPath = MakePathFromRootDir(
                Path.Combine(libDir, @"Microsoft FxCop 1.36\FxCopCmd.exe"));

            AssertFileExists("FxCopCmd.exe", fxCopCmdPath);
            ProgramRunner.Run(fxCopCmdPath, true);

            // check if the report file was generated
            bool isReportFileGenerated = File.Exists(fxReportPath);

            // FxCop returns different exit codes for different things
            // see http://msdn.microsoft.com/en-us/library/bb164705(VS.80).aspx for the list of exit codes
            // exit code 4 means "Project load error" but it occurs when the old FxCop violations exist
            // which are then removed from the code
            if ((ProgramRunner.LastExitCode != 0 && ProgramRunner.LastExitCode != 4) || isReportFileGenerated)
            {
                if (IsRunningUnderCruiseControl)
                {
                    if (File.Exists(fxReportPath))
                    {
                        string fxcopReportFileName = Path.GetFileName(fxReportPath);
                        try
                        {
                            CopyFile(fxReportPath, Path.Combine(ccnetDir, fxcopReportFileName), true);
                        }
                        catch (IOException)
                        {
                            Log(
                                "Warning: could not copy FxCop report file '{0}' to the CC.NET dir",
                                fxReportPath);
                        }
                    }
                }
                else if (IsRunningUnderHudson)
                {
                }
                else
                {
                    // run FxCop GUI
                    ProgramRunner
                    .AddArgument(fxProjectPath)
                    .Run(MakePathFromRootDir(Path.Combine(libDir, @"Microsoft FxCop 1.36\FxCop.exe")));
                }

                Fail("FxCop found violations in the code.");
            }

            ScriptExecutionEnvironment.LogTaskFinished();
            return(ReturnThisTRunner());
        }