/// ------------------------------------------------------------------------------------ /// <summary> /// Checks if at least one of the targets exists in the build file. /// </summary> /// <param name="buildfile">The name of the build file</param> /// <param name="projectNames">The target(s)</param> /// <param name="baseDir">The base directory</param> /// <returns><c>true</c> if the target exists in the build file.</returns> /// ------------------------------------------------------------------------------------ private bool TargetExists(string buildfile, string projectNames, string baseDir) { string addinDir = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location); string cmdLine = string.Format( "-nologo -buildfile:\"{0}\\addin.build.xml\" -D:possibleTargets=\"{1}\" " + "-D:buildfile=\"{2}\" -D:fwroot=\"{3}\"", addinDir, projectNames, buildfile, baseDir); #if DEBUG NantRunner runner = new NantRunner(NAnt, cmdLine, addinDir, new AddinLogListener(this, true), new NantRunner.BuildStatusHandler(BuildStatusChange)); #else NantRunner runner = new NantRunner(NAnt, cmdLine, addinDir, new AddinLogListener(null, true), new NantRunner.BuildStatusHandler(BuildStatusChange)); #endif return(runner.RunSync() == 0); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Checks if at least one of the targets exists in the build file. /// </summary> /// <param name="buildfile">The name of the build file</param> /// <param name="projectNames">The target(s)</param> /// <param name="baseDir">The base directory</param> /// <returns><c>true</c> if the target exists in the build file.</returns> /// ------------------------------------------------------------------------------------ private bool TargetExists(string buildfile, string projectNames, string baseDir) { string addinDir = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location); string cmdLine = string.Format( "-nologo -buildfile:\"{0}\\addin.build.xml\" -D:possibleTargets=\"{1}\" " + "-D:buildfile=\"{2}\" -D:fwroot=\"{3}\"", addinDir, projectNames, buildfile, baseDir); #if DEBUG NantRunner runner = new NantRunner(NAnt, cmdLine, addinDir, new AddinLogListener(this, true), new NantRunner.BuildStatusHandler(BuildStatusChange)); #else NantRunner runner = new NantRunner(NAnt, cmdLine, addinDir, new AddinLogListener(null, true), new NantRunner.BuildStatusHandler(BuildStatusChange)); #endif return runner.RunSync() == 0; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Perform the build with NAnt /// </summary> /// <param name="projectName">Name(s) of the target</param> /// <param name="config">Configuration (Debug/Release...)</param> /// <param name="fRebuild"><c>true</c> to perform a rebuild</param> /// <param name="projectPath">Full path to the project</param> /// <param name="fWait"><c>true</c> to wait for the build to finish</param> /// <returns><c>true</c> if the build was successful</returns> /// <exception cref="TargetException">If target doesn't exist, so that a NAnt build /// can't be performed.</exception> /// ------------------------------------------------------------------------------------ private bool InternalBuildProject(Modifiers mods, string projectName, string config, bool fRebuild, string projectPath, bool fWait) { try { string buildFile = string.Empty; string fwroot = string.Empty; RetrieveBuildFile(projectPath, out buildFile, out fwroot); FindTarget(ref buildFile, ref projectName, fwroot, projectPath); m_buildFile = buildFile; //string cmdLine = string.Format("-buildfile:\"c:\\fwtexp\\bin\\FieldWorks.build\" VSCompile -D:sln=\"{0}\"", string action; if (mods.fClean) { action = "clean"; } else if (mods.fTest) { if (mods.fForceTests) { action = "forcetests test"; } else { action = "test"; } } else { action = "buildtest"; } string cmdLine = string.Format( "-e+ -nologo -buildfile:\"{0}\" {1} {2} {3}", buildFile, action, config, projectName); string workingDirectory = Path.GetFullPath(Path.GetDirectoryName(buildFile)); OutputBuild.Activate(); m_nantRunner = new NantRunner(NAnt, cmdLine, workingDirectory, new AddinLogListener(this, false), new NantRunner.BuildStatusHandler(BuildStatusChange)); if (fWait) { if (m_nantRunner.RunSync() != 0) { return(false); } } else { m_nantRunner.Run(); } } catch (TargetException) { throw; } 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); return(false); } return(true); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Perform the build with NAnt /// </summary> /// <param name="projectName">Name(s) of the target</param> /// <param name="config">Configuration (Debug/Release...)</param> /// <param name="fRebuild"><c>true</c> to perform a rebuild</param> /// <param name="projectPath">Full path to the project</param> /// <param name="fWait"><c>true</c> to wait for the build to finish</param> /// <returns><c>true</c> if the build was successful</returns> /// <exception cref="TargetException">If target doesn't exist, so that a NAnt build /// can't be performed.</exception> /// ------------------------------------------------------------------------------------ private bool InternalBuildProject(Modifiers mods, string projectName, string config, bool fRebuild, string projectPath, bool fWait) { try { string buildFile = string.Empty; string fwroot = string.Empty; RetrieveBuildFile(projectPath, out buildFile, out fwroot); FindTarget(ref buildFile, ref projectName, fwroot, projectPath); m_buildFile = buildFile; //string cmdLine = string.Format("-buildfile:\"c:\\fwtexp\\bin\\FieldWorks.build\" VSCompile -D:sln=\"{0}\"", string action; if (mods.fClean) action = "clean"; else if (mods.fTest) { if (mods.fForceTests) action = "forcetests test"; else action = "test"; } else action = "buildtest"; string cmdLine = string.Format( "-e+ -nologo -buildfile:\"{0}\" {1} {2} {3}", buildFile, action, config, projectName); string workingDirectory = Path.GetFullPath(Path.GetDirectoryName(buildFile)); OutputBuild.Activate(); m_nantRunner = new NantRunner(NAnt, cmdLine, workingDirectory, new AddinLogListener(this, false), new NantRunner.BuildStatusHandler(BuildStatusChange)); if (fWait) { if (m_nantRunner.RunSync() != 0) { return false; } } else m_nantRunner.Run(); } catch(TargetException) { throw; } 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); return false; } return true; }