本文整理汇总了C#中NAnt.Core.Project.ExpandProperties方法的典型用法代码示例。如果您正苦于以下问题:C# Project.ExpandProperties方法的具体用法?C# Project.ExpandProperties怎么用?C# Project.ExpandProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NAnt.Core.Project
的用法示例。
在下文中一共展示了Project.ExpandProperties方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Initialization_FSBuildFile
public void Test_Initialization_FSBuildFile() {
// create the build file in the temp folder
TempFile.CreateWithContents(FormatBuildFile("", ""), _buildFileName);
Project p = new Project(_buildFileName, Level.Error, 0);
Assert.IsNotNull(p.Properties["nant.version"], "Property ('nant.version') not defined.");
Assert.IsNotNull(p.Properties["nant.location"], "Property ('nant.location') not defined.");
Assert.AreEqual(new Uri(_buildFileName), p.Properties["nant.project.buildfile"]);
Assert.AreEqual(TempDirName, p.Properties["nant.project.basedir"]);
Assert.AreEqual("test", p.Properties["nant.project.default"]);
CheckCommon(p);
Assert.AreEqual("The value is " + Boolean.TrueString + ".", p.ExpandProperties("The value is ${task::exists('fail')}.", null));
}
示例2: TryExpandingProperty
private static void TryExpandingProperty(Project project, IBuildProperty property)
{
try
{
property.DefaultExpandedValue =
property.ExpandedValue =
project.ExpandProperties(property.Value, new Location("Buildfile"));
}
catch (BuildException)
{
// TODO: Do something with the error message
}
}
示例3: FollowIncludes
private void FollowIncludes(Project project, XmlDocument doc)
{
foreach (XmlElement element in doc.GetElementsByTagName("include"))
{
string buildFile = element.GetAttribute("buildfile");
string filename = project.ExpandProperties(buildFile, new Location("Buildfile"));
ParseIncludeFile(project, filename);
}
}
示例4: 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
//.........这里部分代码省略.........
示例5: 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;
}
示例6: Test_Initialization_DOMBuildFile
public void Test_Initialization_DOMBuildFile() {
XmlDocument doc = new XmlDocument();
doc.LoadXml(FormatBuildFile("", ""));
Project p = new Project(doc, Level.Error, 0);
Assert.IsNotNull(p.Properties["nant.version"], "Property not defined.");
Assert.IsNull(p.Properties["nant.project.buildfile"], "location of buildfile should not exist!");
Assert.IsNotNull(p.Properties["nant.project.basedir"], "nant.project.basedir should not be null");
Assert.AreEqual(TempDirName, p.Properties["nant.project.basedir"]);
Assert.AreEqual("test", p.Properties["nant.project.default"]);
CheckCommon(p);
Assert.AreEqual("The value is " + Boolean.TrueString + ".", p.ExpandProperties("The value is ${task::exists('fail')}.", null));
}
示例7: TaskExists
private bool TaskExists (Project p, string taskName) {
string val = p.ExpandProperties("${task::exists('" + taskName + "')}",
Location.UnknownLocation);
return val == Boolean.TrueString;
}
示例8: GatherModuleDpdFromCustmizedSlnMaker
/// START: TO BE REMOVED
void GatherModuleDpdFromCustmizedSlnMaker(Project proj, string config, string group, XmlNode xmlNode, ref string needRunCrossConfig)
{
string projName = proj.Properties["package.name"];
XmlAttribute pathAttribute, nameAttribute, modulesAttribute, groupAttribute;
XmlNodeList nodeList = xmlNode.SelectNodes("./project");
for (int i = 0; i < nodeList.Count; i++)
{
if (!GetConditionAttribute(nodeList.Item(i), "project")) continue;
pathAttribute = nodeList.Item(i).Attributes["path"];
nameAttribute = nodeList.Item(i).Attributes["name"];
modulesAttribute = nodeList.Item(i).Attributes["modules"];
groupAttribute = nodeList.Item(i).Attributes["group"];
if (groupAttribute == null && pathAttribute == null)
{
if (modulesAttribute != null)
{
string bm = "";
if (nameAttribute == null || (nameAttribute != null && nameAttribute.InnerText == projName))
{
bm = proj.ExpandProperties(modulesAttribute.InnerText);
}
if (bm != "")
{
XmlAttribute pathDepAttribute, nameDepAttribute, modulesDepAttribute;
XmlNodeList oNodeListDep = nodeList.Item(i).SelectNodes("./depends");
// we assume all dependent modules belong to the group ${group}
string crossmoduledependentlist = "";
string nativemoduledependentlist = "";
for (int j = 0; j < oNodeListDep.Count; j++)
{
pathDepAttribute = oNodeListDep.Item(j).Attributes["path"];
nameDepAttribute = oNodeListDep.Item(j).Attributes["name"];
modulesDepAttribute = oNodeListDep.Item(j).Attributes["modules"];
if (pathDepAttribute == null && nameDepAttribute == null && modulesDepAttribute != null)
{
foreach (string dpm in NantToVSTools.TrimAndSplit(proj.ExpandProperties(modulesDepAttribute.InnerText)))
{
if (dpm == string.Empty) continue;
if (dpm.StartsWith("cross-")) // if found a cross dependent module
crossmoduledependentlist = crossmoduledependentlist + " " + dpm;
else
nativemoduledependentlist = nativemoduledependentlist + " " + dpm;
}
}
}
if (crossmoduledependentlist != "")
{
needRunCrossConfig = "true";
foreach (string item in NantToVSTools.TrimAndSplit(bm))
{
if (item == string.Empty) continue;
string crossConfig = proj.Properties["config-cross"] + "-" + proj.Properties["config-name"];
if (item.StartsWith("cross"))
{
string constrainProperty = projName + "." + group + ".buildmodules";
if (_properties.Contains(constrainProperty + "." + config))
{
string existingModules = (string)_properties[constrainProperty + "." + config];
if (existingModules != "") // if it's empty, then it means it depends on everything
{
_properties[constrainProperty + "." + config] = CombineStrings(existingModules, crossmoduledependentlist);
}
}
else
{
_properties[constrainProperty + "." + config] = crossmoduledependentlist;
}
}
else
{
// we assume in customized slnmaker only [example|tool|test] modules dependencies, no inter-group module dependenices except depending on 'runtime'
if (_native2crossmoduledependencies.Contains(projName + "." + group + ".buildmodules." + config + ".md." + item))
{
_native2crossmoduledependencies[projName + "." + group + ".buildmodules." + config + ".md." + item] =
((string)_native2crossmoduledependencies[projName + "." + group + ".buildmodules." + config + ".md." + item]) + " " + crossmoduledependentlist;
}
else
_native2crossmoduledependencies.Add(projName + "." + group + ".buildmodules." + config + ".md." + item, crossConfig + "." + group + "." + crossmoduledependentlist);
}
}
}
if (nativemoduledependentlist != "") // this is only true when we have native [example|test|tool] module dependencies in customized slnmaker
{
if (config.IndexOf("cross") != -1)
Console.WriteLine("WARNING: Cross2Native module dependency found! " + bm + " depend(s) on " + nativemoduledependentlist);
string constrainProperty = projName + "." + group + ".buildmodules";
if (_properties.Contains(constrainProperty + "." + config))
{
string existingModules = (string)_properties[constrainProperty + "." + config];
if (existingModules != "") // if it's empty, then it means it depends on everything
{
_properties[constrainProperty + "." + config] = CombineStrings(existingModules, nativemoduledependentlist);
}
}
else
{
_properties[constrainProperty + "." + config] = nativemoduledependentlist;
}
//.........这里部分代码省略.........