Re: csproj/vbproj definition available?



Hello again...

I found the

ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/CPref0/html/T_Microsoft_Build_BuildEngine_Project.htm

document very useful :-)

a Microsoft.Build.BuildEngine.Project class that "Represents a project
that can be built using MSBuild." and A Project represents an MSBuild
project. It is a container for items, properties and targets. It can
load project content from in-memory XML or from an XML file, and can
save to an XML file, preserving most whitespace and all XML comments."

I think that is all I need...

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Build.BuildEngine;

namespace ListItemAndPropertiesCS
{
class Program
{
static void Main(string[] args)
{
// SET THIS TO POINT TO THE RIGHT LOCATION
Engine.GlobalEngine.BinPath =
@"C:\Windows\Microsoft.NET\Framework\v2.0.xxxxx";

// Create a new empty project
Project project = new Project();

// Load a project
project.Load(@"c:\temp\validate.proj");

Console.WriteLine("Project Properties");
Console.WriteLine("----------------------------------");

// Iterate through the various property groups and
subsequently
// through teh various properties
foreach (BuildPropertyGroup propertyGroup in
project.PropertyGroups)
{
foreach (BuildProperty prop in propertyGroup)
{
Console.WriteLine("{0}:{1}", prop.Name,
prop.Value);
}
}

Console.WriteLine();
Console.WriteLine("Project Items");
Console.WriteLine("----------------------------------");

// Iterate through the various itemgroups
// and subsequently through the items
foreach (BuildItemGroup itemGroup in project.ItemGroups)
{
foreach (BuildItem item in itemGroup)
{
Console.WriteLine("{0}:{1}", item.Name,
item.Include);
}
}
}
}
}


/Magnus

.



Relevant Pages

  • Re: Best thing to simulate an Ini file
    ... > Use a simple class to read and write to a configuration file on either the ... Here's a sample of the xml file and a class to ... > foreach (XmlNode node in configDocument.ChildNodes) ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: MsBuild
    ... You might want to delete the .config ... Its the XCOPY working. ... MSBuild fromhttp://msbuildtasks.tigris.org/. ... Do you know how to reference in the XML file the path of the project ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: XML::LibXML navigation
    ... I have to do some sanity checks on a large xml file of addresses. ... I can locate them easily enough but I am struggling to navigate back up the DOM to access the code so I can record the code with faulty addresses. ... foreach my $l { ...
    (perl.beginners)
  • Re: Saving configuration to file in C#?
    ... A simple xml file can be used on device for this purpose and also as a place ... foreach (XmlNode node in configDocument.ChildNodes) ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Best thing to simulate an Ini file
    ... Use a simple class to read and write to a configuration file on either the ... Here's a sample of the xml file and a class to ... foreach (XmlNode node in configDocument.ChildNodes) ...
    (microsoft.public.dotnet.framework.compactframework)

Loading