本文整理汇总了C#中Microsoft.Build.BuildEngine.Project类的典型用法代码示例。如果您正苦于以下问题:C# Project类的具体用法?C# Project怎么用?C# Project使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Project类属于Microsoft.Build.BuildEngine命名空间,在下文中一共展示了Project类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BuildItemGroup
internal BuildItemGroup (XmlElement xmlElement, Project project, ImportedProject importedProject, bool readOnly, bool dynamic)
{
this.buildItems = new List <BuildItem> ();
this.importedProject = importedProject;
this.itemGroupElement = xmlElement;
this.parentProject = project;
this.read_only = readOnly;
this.isDynamic = dynamic;
if (!FromXml)
return;
foreach (XmlNode xn in xmlElement.ChildNodes) {
if (!(xn is XmlElement))
continue;
XmlElement xe = (XmlElement) xn;
BuildItem bi = CreateItem (project, xe);
buildItems.Add (bi);
project.LastItemGroupContaining [bi.Name] = this;
}
DefinedInFileName = importedProject != null ? importedProject.FullFileName :
project != null ? project.FullFileName : null;
}
开发者ID:nlhepler,项目名称:mono,代码行数:25,代码来源:BuildItemGroup.cs
示例2: AddUnloadedProjectRecord
/// <summary>
/// Searches our tables for a project with same full path, tools version, and global property settings
/// Removes particular project from the project manager.
/// </summary>
/// <param name="project"></param>
internal void RemoveProject
(
Project project
)
{
// We should never be asked to remove null project
ErrorUtilities.VerifyThrow(project != null, "Shouldn't ask to remove null projects");
// See if there's an entry in our table for this particular full path.
ArrayList projectsWithThisFullPath = (ArrayList)this.projects[project.FullFileName];
// The project should be in the table
ErrorUtilities.VerifyThrow(projectsWithThisFullPath != null, "Project missing from the list");
int project_index = -1;
for (int i = 0; i < projectsWithThisFullPath.Count; i++)
{
if (projectsWithThisFullPath[i] == project)
{
project_index = i;
}
}
// The project should be in the table
ErrorUtilities.VerifyThrow(project_index != -1, "Project missing from the list");
if (project_index != -1)
{
projectsWithThisFullPath.RemoveAt(project_index);
AddUnloadedProjectRecord(project.FullFileName, project.GlobalProperties, project.ToolsVersion);
}
}
开发者ID:nikson,项目名称:msbuild,代码行数:37,代码来源:ProjectManager.cs
示例3: Target
internal Target (XmlElement targetElement, Project project, ImportedProject importedProject)
{
if (project == null)
throw new ArgumentNullException ("project");
if (targetElement == null)
throw new ArgumentNullException ("targetElement");
this.targetElement = targetElement;
this.name = targetElement.GetAttribute ("Name");
this.project = project;
this.engine = project.ParentEngine;
this.importedProject = importedProject;
this.onErrorElements = new List <XmlElement> ();
this.buildState = BuildState.NotStarted;
this.buildTasks = new List <BuildTask> ();
this.batchingImpl = new TargetBatchingImpl (project, this.targetElement);
bool onErrorFound = false;
foreach (XmlNode xn in targetElement.ChildNodes) {
if (xn is XmlElement) {
XmlElement xe = (XmlElement) xn;
if (xe.Name == "OnError") {
onErrorElements.Add (xe);
onErrorFound = true;
} else if (onErrorFound)
throw new InvalidProjectFileException (
"The element <OnError> must be last under element <Target>. Found element <Error> instead.");
else
buildTasks.Add (new BuildTask (xe, this));
}
}
}
开发者ID:carrie901,项目名称:mono,代码行数:34,代码来源:Target.cs
示例4: TestFromXml2
public void TestFromXml2 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Target Name='Target' Condition='false' DependsOnTargets='X' >
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Target[] t = new Target [1];
project.Targets.CopyTo (t, 0);
Assert.AreEqual ("false", t [0].Condition, "A1");
Assert.AreEqual ("X", t [0].DependsOnTargets, "A2");
t [0].Condition = "true";
t [0].DependsOnTargets = "A;B";
Assert.AreEqual ("true", t [0].Condition, "A3");
Assert.AreEqual ("A;B", t [0].DependsOnTargets, "A4");
}
开发者ID:ancailliau,项目名称:mono,代码行数:26,代码来源:TargetTest.cs
示例5: GetAssemblyNameScalarThatIsNotSet
public void GetAssemblyNameScalarThatIsNotSet()
{
Project p = new Project(new Engine());
p.AddNewUsingTaskFromAssemblyName("TaskName", @"$(assemblyName)");
object o = p.EvaluatedItems;
Assertion.AssertEquals(@"$(assemblyName)", CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).AssemblyName);
}
开发者ID:nikson,项目名称:msbuild,代码行数:7,代码来源:UsingTask_Tests.cs
示例6: GetAssemblyNameSpecialCharsEscaped
public void GetAssemblyNameSpecialCharsEscaped()
{
Project p = new Project(new Engine());
p.AddNewUsingTaskFromAssemblyName("TaskName", @"%25%2a%3f%40%24%28%29%3b\");
object o = p.EvaluatedItems;
Assertion.AssertEquals(@"%25%2a%3f%40%24%28%29%3b\", CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).AssemblyName);
}
开发者ID:nikson,项目名称:msbuild,代码行数:7,代码来源:UsingTask_Tests.cs
示例7: Parse
static void Parse(String file)
{
var obj = JObject.Parse(Console.In.ReadToEnd());
var solution = new Project();
solution.ParentEngine.RegisterLogger(new ConsoleLogger());
foreach (var prop in obj)
{
solution.GlobalProperties[prop.Key] = new BuildProperty(prop.Key, prop.Value.ToString());
}
using (PlatformProjectHelper.Instance.Load(solution, file))
{
var result = ToJson(solution);
if (Path.GetExtension(file) == ".sln")
{
var jSolution = result;
result = new JObject();
result["Solution"] = jSolution;
foreach (var proj in PlatformProjectHelper.Instance.GetBuildLevelItems(solution))
{
var project = solution.ParentEngine.CreateNewProject();
foreach (var meta in PlatformProjectHelper.Instance.GetEvaluatedMetadata(proj))
{
project.GlobalProperties[meta.Item1] = new BuildProperty(meta.Item1, meta.Item2);
}
using (PlatformProjectHelper.Instance.Load(project, proj.FinalItemSpec))
{
var jProject = ToJson(project);
result[Path.GetFileNameWithoutExtension(proj.FinalItemSpec)] = jProject;
}
}
}
Console.WriteLine(result.ToString());
}
}
开发者ID:redrezo,项目名称:gradle-msbuild-plugin,代码行数:34,代码来源:Program.cs
示例8: SetUp
public void SetUp()
{
// Whole bunch of setup code.
XmlElement taskNode = new XmlDocument().CreateElement("MockTask");
LoadedType taskClass = new LoadedType(typeof(MockTask), new AssemblyLoadInfo(typeof(MockTask).Assembly.FullName, null));
Engine engine = new Engine(@"c:\");
loggingHelper = new EngineLoggingServicesHelper();
engine.LoggingServices = loggingHelper;
Project project = new Project(engine);
taskExecutionModule = new MockTaskExecutionModule(new EngineCallback(engine));
// Set up some "fake data" which will be passed to the Task Execution State object
Hashtable[] fakeArray = new Hashtable[1];
fakeArray[0] = new Hashtable();
projectLevelProprtiesForInference = new BuildPropertyGroup();
projectLevelPropertiesForExecution = new BuildPropertyGroup();
inferenceBucketItemsByName = fakeArray;
inferenceBucketMetaData = fakeArray;
projectLevelItemsForInference = new Hashtable();
executionBucketItemsByName = fakeArray;
executionBucketMetaData = fakeArray;
projectLevelItemsForExecution = new Hashtable();
hostObject = null;
projectFileOfTaskNode = "In Memory";
parentProjectFullFileName = project.FullFileName;
nodeProxyId = engine.EngineCallback.CreateTaskContext(project, null, null, taskNode, EngineCallback.inProcNode, new BuildEventContext(BuildEventContext.InvalidNodeId, BuildEventContext.InvalidTargetId, BuildEventContext.InvalidProjectContextId, BuildEventContext.InvalidTaskId));
executionDirectory = Directory.GetCurrentDirectory();
projectId = project.Id;
}
开发者ID:nikson,项目名称:msbuild,代码行数:28,代码来源:TaskExecutionState_Test.cs
示例9: CompileSingle
protected override bool CompileSingle(Engine engine, AbstractBaseGenerator gen, string workingPath, string target)
{
try
{
using (log4net.NDC.Push("Compiling " + gen.Description))
{
Log.DebugFormat("Loading MsBuild Project");
var proj = new Project(engine);
proj.Load(Helper.PathCombine(workingPath, gen.TargetNameSpace, gen.ProjectFileName));
Log.DebugFormat("Compiling");
if (engine.BuildProject(proj, target))
{
return true;
}
else
{
Log.ErrorFormat("Failed to compile {0}", gen.Description);
return false;
}
}
}
catch (Exception ex)
{
Log.Error("Failed compiling " + gen.Description, ex);
return false;
}
}
开发者ID:jrgcubano,项目名称:zetbox,代码行数:28,代码来源:MsBuildCompiler.cs
示例10: Execute
public override bool Execute()
{
bool result = true;
string file = Path.Combine(m_stubsPath, m_name + ".featureproj");
try
{
Project proj = new Project();
proj.DefaultToolsVersion = "3.5";
proj.DefaultTargets = "Build";
BuildPropertyGroup bpg = proj.AddNewPropertyGroup(true);
bpg.AddNewProperty("FeatureName", m_name);
bpg.AddNewProperty("Guid", System.Guid.NewGuid().ToString("B"));
bpg.AddNewProperty("Description", "");
bpg.AddNewProperty("Groups", "");
BuildItemGroup big = proj.AddNewItemGroup();
big.AddNewItem("InteropFeature", Path.GetFileNameWithoutExtension(m_assemblyName).Replace('.', '_'));
big.AddNewItem("DriverLibs", Path.GetFileNameWithoutExtension( m_assemblyName ).Replace( '.', '_' ) + ".$(LIB_EXT)");
big.AddNewItem("MMP_DAT_CreateDatabase", "$(BUILD_TREE_CLIENT)\\pe\\" + m_assemblyName);
big.AddNewItem("RequiredProjects", Path.Combine(m_stubsPath, m_nativeProjectFile));
proj.Save(file);
}
catch(Exception e)
{
Log.LogError("Error trying to create feature project file \"" + file + "\": " + e.Message);
result = false;
}
return result;
}
开发者ID:prabby,项目名称:miniclr,代码行数:34,代码来源:CreateInteropFeatureProj.cs
示例11: Setup
public void Setup()
{
ccu = new CodeCompileUnit();
mocks = new MockRepository();
engine = Engine.GlobalEngine;
engine.BinPath = @"C:\Program Files (x86)\MSBuild";
project = new Project();
buildEngine = mocks.DynamicMock<MockBuildEngine>(project);
logger = new NullLogger();
parserService = mocks.DynamicMock<ISiteTreeGeneratorService>();
naming = mocks.DynamicMock<INamingService>();
sourceStorage = mocks.DynamicMock<IParsedSourceStorageService>();
source = mocks.DynamicMock<ISourceGenerator>();
typeResolver = mocks.DynamicMock<ITypeResolver>();
treeService = mocks.DynamicMock<ITreeCreationService>();
viewSourceMapper = mocks.DynamicMock<IViewSourceMapper>();
generator = mocks.DynamicMock<IGenerator>();
task = new GenerateMonoRailSiteTreeTask(logger, parserService, naming, source, sourceStorage, typeResolver,
treeService, viewSourceMapper, generator);
item = mocks.DynamicMock<ITaskItem>();
parsedSource = mocks.DynamicMock<IParser>();
}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:25,代码来源:GenerateMonoRailSiteTreeTaskTests.cs
示例12: BoolEvaluate
public override bool BoolEvaluate (Project context)
{
if (left.CanEvaluateToNumber (context) && right.CanEvaluateToNumber (context)) {
float l,r;
l = left.NumberEvaluate (context);
r = right.NumberEvaluate (context);
return NumberCompare (l, r, op);
} else if (left.CanEvaluateToBool (context) && right.CanEvaluateToBool (context)) {
bool l,r;
l = left.BoolEvaluate (context);
r = right.BoolEvaluate (context);
return BoolCompare (l, r, op);
} else {
string l,r;
l = left.StringEvaluate (context);
r = right.StringEvaluate (context);
return StringCompare (l, r, op);
}
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:25,代码来源:ConditionRelationalExpression.cs
示例13: ProjectInfo
public ProjectInfo(Project project)
{
_project = project;
_properties = new ProjectPropertyList(_project);
_references = new ReferenceList(_project);
_dependencies = new List<string>();
}
开发者ID:hivie7510,项目名称:csharptest-net,代码行数:7,代码来源:ProjectInfo.cs
示例14: Initialize
public void Initialize()
{
ObjectModelHelpers.DeleteTempProjectDirectory();
engine = new Engine();
project = new Project(engine);
}
开发者ID:nikson,项目名称:msbuild,代码行数:7,代码来源:BuildItemGroupCollection_Tests.cs
示例15: Execute
/// <summary>
/// Executes this instance.
/// </summary>
public override bool Execute() {
foreach (var projectTaskItem in this.Projects) {
var project = new Project();
project.Load(projectTaskItem.ItemSpec);
foreach (var projectItem in this.Items) {
string itemType = projectItem.GetMetadata("ItemType");
if (string.IsNullOrEmpty(itemType)) {
itemType = "None";
}
BuildItem newItem = project.AddNewItem(itemType, projectItem.ItemSpec, false);
var customMetadata = projectItem.CloneCustomMetadata();
foreach (DictionaryEntry entry in customMetadata) {
string value = (string)entry.Value;
if (value.Length > 0) {
newItem.SetMetadata((string)entry.Key, value);
}
}
}
project.Save(projectTaskItem.ItemSpec);
}
return !this.Log.HasLoggedErrors;
}
开发者ID:jongalloway,项目名称:dotnetopenid,代码行数:28,代码来源:AddProjectItems.cs
示例16: BuildWhen
public BuildWhen (XmlElement whenElement, Project parentProject)
{
this.parentProject = parentProject;
this.groupingCollection = new GroupingCollection (parentProject);
if (whenElement == null)
throw new ArgumentNullException ("whenElement");
this.whenElement = whenElement;
foreach (XmlElement xe in whenElement.ChildNodes) {
switch (xe.Name) {
case "ItemGroup":
BuildItemGroup big = new BuildItemGroup (xe, parentProject, null, true);
//big.BindToXml (xe);
groupingCollection.Add (big);
break;
case "PropertyGroup":
BuildPropertyGroup bpg = new BuildPropertyGroup (xe, parentProject, null, true);
//bpg.BindToXml (xe);
groupingCollection.Add (bpg);
break;
case "Choose":
BuildChoose bc = new BuildChoose (xe, parentProject);
groupingCollection.Add (bc);
break;
default:
throw new InvalidProjectFileException ( string.Format ("Invalid element '{0}' in When.", xe.Name));
}
}
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:28,代码来源:BuildWhen.cs
示例17: TestAssemblyFile2
public void TestAssemblyFile2 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<UsingTask
AssemblyFile='Test/resources/TestTasks.dll'
TaskName='SimpleTask'
/>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
IEnumerator en = project.UsingTasks.GetEnumerator ();
en.MoveNext ();
UsingTask ut = (UsingTask) en.Current;
Assert.AreEqual ("Test/resources/TestTasks.dll", ut.AssemblyFile, "A1");
Assert.IsNull (ut.AssemblyName, "A2");
Assert.AreEqual (null, ut.Condition, "A3");
Assert.AreEqual (false, ut.IsImported, "A4");
Assert.AreEqual ("SimpleTask", ut.TaskName, "A5");
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:26,代码来源:UsingTaskTest.cs
示例18: BatchingImplBase
protected BatchingImplBase (Project project)
{
if (project == null)
throw new ArgumentNullException ("project");
this.project = project;
}
开发者ID:carrie901,项目名称:mono,代码行数:7,代码来源:BatchingImplBase.cs
示例19: SimpleAddAndRetrieveProject
public void SimpleAddAndRetrieveProject()
{
// Initialize engine.
Engine engine = new Engine(@"c:\");
// Instantiate new project manager.
ProjectManager projectManager = new ProjectManager();
// Set up variables that represent the information we would be getting from
// the "MSBuild" task.
string fullPath = @"c:\rajeev\temp\myapp.proj";
BuildPropertyGroup globalProperties = new BuildPropertyGroup();
globalProperties.SetProperty("Configuration", "Debug");
// Create a new project that matches the information that we're pretending
// to receive from the MSBuild task.
Project project1 = new Project(engine);
project1.FullFileName = fullPath;
project1.GlobalProperties = globalProperties;
// Add the new project to the ProjectManager.
projectManager.AddProject(project1);
// Try and retrieve the project from the ProjectManager based on the fullpath + globalprops,
// and make sure we get back the same project we added.
Assertion.AssertEquals(project1, projectManager.GetProject(fullPath, globalProperties, null));
}
开发者ID:nikson,项目名称:msbuild,代码行数:27,代码来源:ProjectManager_Tests.cs
示例20: BuildPropertyGroup
internal BuildPropertyGroup (XmlElement xmlElement, Project project, ImportedProject importedProject, bool readOnly, bool isDynamic)
{
this.importedProject = importedProject;
this.parentCollection = null;
this.parentProject = project;
this.propertyGroup = xmlElement;
this.read_only = readOnly;
this.isDynamic = isDynamic;
if (FromXml) {
this.properties = new List <BuildProperty> ();
foreach (XmlNode xn in propertyGroup.ChildNodes) {
if (!(xn is XmlElement))
continue;
XmlElement xe = (XmlElement) xn;
BuildProperty bp = new BuildProperty (parentProject, xe);
AddProperty (bp);
}
} else
this.propertiesByName = new Dictionary <string, BuildProperty> (StringComparer.OrdinalIgnoreCase);
DefinedInFileName = importedProject != null ? importedProject.FullFileName :
(project != null ? project.FullFileName : null);
}
开发者ID:nlhepler,项目名称:mono,代码行数:25,代码来源:BuildPropertyGroup.cs
注:本文中的Microsoft.Build.BuildEngine.Project类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论