本文整理汇总了C#中NAnt.Core.Project.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# Project.Execute方法的具体用法?C# Project.Execute怎么用?C# Project.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NAnt.Core.Project
的用法示例。
在下文中一共展示了Project.Execute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DummyCircularReferenceTask
public DummyCircularReferenceTask(string references, string buildFileXml)
{
m_References = references;
XmlDocument doc = new XmlDocument();
doc.LoadXml(buildFileXml);
Project = new Project(doc, Level.Info, 1);
Project.Execute(); // this loads targets
}
示例2: ProcessFrameworks
/// <summary>
/// Processes the framework nodes of the given platform node.
/// </summary>
/// <param name="platformNode">An <see cref="XmlNode" /> representing the platform on which NAnt is running.</param>
private void ProcessFrameworks(XmlNode platformNode)
{
// determine the framework family name
string frameworkFamily = PlatformHelper.IsMono ? "mono" : "net";
// determine the version of the current runtime framework
string frameworkClrVersion = Environment.Version.ToString(3);
// determine default targetframework
string defaultTargetFramework = GetXmlAttributeValue(platformNode, "default");
// deals with xml info from the config file, not build document.
foreach (XmlNode frameworkNode in platformNode.SelectNodes("nant:framework", NamespaceManager)) {
// skip special elements like comments, pis, text, etc.
if (!(frameworkNode.NodeType == XmlNodeType.Element)) {
continue;
}
string name = null;
bool isRuntimeFramework = false;
try {
// get framework attributes
name = GetXmlAttributeValue(frameworkNode, "name");
string family = GetXmlAttributeValue(frameworkNode, "family");
string clrVersion = GetXmlAttributeValue(frameworkNode, "clrversion");
// check if we're processing the current runtime framework
if (family == frameworkFamily && clrVersion == frameworkClrVersion) {
isRuntimeFramework = true;
}
// get framework-specific project node
XmlNode projectNode = frameworkNode.SelectSingleNode("nant:project",
NamespaceManager);
if (projectNode == null) {
throw new BuildException("<project> node has not been defined.");
}
string tempBuildFile = Path.GetTempFileName();
XmlTextWriter writer = null;
Project frameworkProject = null;
try {
// write project to file
writer = new XmlTextWriter(tempBuildFile, Encoding.UTF8);
writer.WriteStartDocument(true);
writer.WriteRaw(projectNode.OuterXml);
writer.Flush();
writer.Close();
// use StreamReader to load build file from to avoid
// having location information as part of the error
// messages
using (StreamReader sr = new StreamReader(new FileStream(tempBuildFile, FileMode.Open, FileAccess.Read, FileShare.Write), Encoding.UTF8)) {
XmlDocument projectDoc = new XmlDocument();
projectDoc.Load(sr);
// create and execute project
frameworkProject = new Project(projectDoc, Level.None, 0, (XmlNode) null);
frameworkProject.BaseDirectory = AppDomain.CurrentDomain.BaseDirectory;
frameworkProject.Execute();
}
} finally {
if (writer != null) {
writer.Close();
}
if (File.Exists(tempBuildFile)) {
File.Delete(tempBuildFile);
}
}
string description = frameworkProject.ExpandProperties(
GetXmlAttributeValue(frameworkNode, "description"),
Location.UnknownLocation);
string version = frameworkProject.ExpandProperties(
GetXmlAttributeValue(frameworkNode, "version"),
Location.UnknownLocation);
string runtimeEngine = frameworkProject.ExpandProperties(
GetXmlAttributeValue(frameworkNode, "runtimeengine"),
Location.UnknownLocation);
string frameworkDir = frameworkProject.ExpandProperties(
GetXmlAttributeValue(frameworkNode, "frameworkdirectory"),
Location.UnknownLocation);
string frameworkAssemblyDir = frameworkProject.ExpandProperties(
GetXmlAttributeValue(frameworkNode, "frameworkassemblydirectory"),
Location.UnknownLocation);
string sdkDir = GetXmlAttributeValue(frameworkNode, "sdkdirectory");
try {
sdkDir = frameworkProject.ExpandProperties(sdkDir,
Location.UnknownLocation);
} catch (BuildException) {
// do nothing with this exception as a framework is still
// considered valid if the sdk directory is not available
//.........这里部分代码省略.........
示例3: ExecuteProject
/// <summary>
/// Executes the project and returns the console output as a string.
/// </summary>
/// <param name="p">The project to execute.</param>
/// <returns>
/// The console output.
/// </returns>
/// <remarks>
/// Any exception that is thrown as part of the execution of the
/// <see cref="Project" /> is wrapped in a <see cref="TestBuildException" />.
/// </remarks>
public static string ExecuteProject(Project p) {
using (ConsoleCapture c = new ConsoleCapture()) {
string output = null;
try {
p.Execute();
} catch (Exception e) {
output = c.Close();
throw new TestBuildException("Error Executing Project", output, e);
} finally {
if(output == null) {
output = c.Close();
}
}
return output;
}
}
示例4: PerformInit
private void PerformInit()
{
// get framework-specific project node
XmlNode projectNode = _frameworkNode.SelectSingleNode("nant:project",
NamespaceManager);
if (projectNode == null)
throw new ArgumentException("No <project> node is defined.");
// create XmlDocument from project node
XmlDocument projectDoc = new XmlDocument();
projectDoc.LoadXml(projectNode.OuterXml);
// create and execute project
Project frameworkProject = new Project(projectDoc);
frameworkProject.BaseDirectory = AppDomain.CurrentDomain.BaseDirectory;
frameworkProject.Execute();
XmlNode runtimeNode = _frameworkNode.SelectSingleNode ("runtime",
NamespaceManager);
if (runtimeNode != null) {
_runtime = new Runtime ();
_runtime.Parent = _runtime.Project = frameworkProject;
_runtime.NamespaceManager = NamespaceManager;
_runtime.Initialize(runtimeNode, frameworkProject.Properties, this);
}
string sdkDir = GetXmlAttributeValue(_frameworkNode, "sdkdirectory");
try {
sdkDir = frameworkProject.ExpandProperties(sdkDir,
Location.UnknownLocation);
} catch (BuildException) {
// do nothing with this exception as a framework is still
// considered valid if the sdk directory is not available
// or not configured correctly
}
// the sdk directory does not actually have to exist for a
// framework to be considered valid
if (sdkDir != null && Directory.Exists(sdkDir))
_sdkDirectory = new DirectoryInfo(sdkDir);
_project = frameworkProject;
_status = InitStatus.Initialized;
}