Example #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Runs Nant.
        /// </summary>
        /// <param name="cmdLine">The CMD line.</param>
        /// ------------------------------------------------------------------------------------
        public void RunNant(string cmdLine)
        {
            if (string.IsNullOrWhiteSpace(cmdLine))
                return;

            try
            {
                var solution = Parent.GetService(typeof(SVsSolution)) as IVsSolution;
                object solutionPath;
                solution.GetProperty((int)__VSPROPID.VSPROPID_SolutionFileName, out solutionPath);
                var buildFile = RetrieveBuildFile(solutionPath as string);

                cmdLine = string.Format("-e+ -buildfile:\"{0}\" {1} {2}", buildFile, TargetFramework, cmdLine);
                var workingDir = Path.GetFullPath(Path.GetDirectoryName(buildFile));

                StartBuild(string.Format("------ Build started: {0} ------\n", cmdLine));
                OutputBuild.Activate();
                m_LogListener = new AddinLogListener(this);
                m_nantRunner = new NantRunner(NAnt, cmdLine, workingDir,
                    m_LogListener,
                    BuildStatusChange);
                m_nantRunner.Run();
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (Exception e)
            {
                if (m_nantRunner != null && m_nantRunner.IsRunning)
                    m_nantRunner.Abort();
                OutputBuild.Write("\nINTERNAL ERROR\n\t");
                OutputBuild.WriteLine(e.Message);
            }
        }