Project.Load Método
Definição
Sobrecargas
| Load(String, ProjectLoadSettings) |
Lê o conteúdo deste projeto de um arquivo XML de projeto em disco.Reads the contents of this project from a project XML file on disk. |
| Load(TextReader, ProjectLoadSettings) |
Lê o conteúdo desse projeto de uma cadeia de caracteres contendo o conteúdo XML.Reads the contents of this project from a string containing the XML contents. |
| Load(TextReader) |
Carrega o conteúdo do TextReader especificado para o objeto Project.Loads the contents of the specified TextReader into the Project object. |
| Load(String) |
Carrega o conteúdo do arquivo de projeto especificado para o objeto Project.Loads the contents of the specified project file into the Project object. |
Exemplos
O exemplo a seguir cria um objeto Project e usa as classes BuildItem, BuildProperty, BuildItemGroup e BuildPropertyGroup para listar todos os itens e propriedades no projeto.The following example creates a Project object and uses the BuildItem, BuildProperty, BuildItemGroup, and BuildPropertyGroup classes to list all the items and properties in the project.
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 the 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);
}
}
}
}
}
Module Module1
'You need to add references to Microsoft.Build.BuildEngine and
'Microsoft.Build.Framework
Sub Main()
'Set this to point to the location where the 2.0 clr/tools are installed
Engine.GlobalEngine.BinPath = "C:\windows\microsoft.net\framework\v2.0.xxxxx"
'Create a new empty project
Dim project As New Project()
'Load a project
project.Load("c:\temp\validate.proj")
'Output a header
Console.WriteLine("Project Properties")
Console.WriteLine("----------------------------------")
'Iterate through the various property groups and subsequently
'through the various properties
For Each propertyGroup As BuildPropertyGroup In project.PropertyGroups
For Each prop As BuildProperty In propertyGroup
Console.WriteLine("{0}:{1}", prop.Name, prop.Value)
Next
Next
Console.WriteLine()
Console.WriteLine("Project Items")
Console.WriteLine("----------------------------------")
'Iterate through the various itemgroups
'and subsequently through the items
For Each itemGroup As BuildItemGroup In project.ItemGroups
For Each item As BuildItem In itemGroup
Console.WriteLine("{0}:{1}", item.Name, item.Include)
Next
Next
End Sub
End Module
Load(String, ProjectLoadSettings)
Lê o conteúdo deste projeto de um arquivo XML de projeto em disco.Reads the contents of this project from a project XML file on disk.
public:
void Load(System::String ^ projectFileName, Microsoft::Build::BuildEngine::ProjectLoadSettings projectLoadSettings);
public void Load (string projectFileName, Microsoft.Build.BuildEngine.ProjectLoadSettings projectLoadSettings);
member this.Load : string * Microsoft.Build.BuildEngine.ProjectLoadSettings -> unit
Public Sub Load (projectFileName As String, projectLoadSettings As ProjectLoadSettings)
Parâmetros
- projectFileName
- String
Uma cadeia de caracteres que representa o nome do arquivo a ser carregado.A string representing the name of the file to load.
- projectLoadSettings
- ProjectLoadSettings
Um valor ProjectLoadSettings que especifica as configurações do projeto que está sendo carregado.A ProjectLoadSettings value that specifies the settings for the project being loaded.
Aplica-se a
Load(TextReader, ProjectLoadSettings)
Lê o conteúdo desse projeto de uma cadeia de caracteres contendo o conteúdo XML.Reads the contents of this project from a string containing the XML contents.
public:
void Load(System::IO::TextReader ^ textReader, Microsoft::Build::BuildEngine::ProjectLoadSettings projectLoadSettings);
public void Load (System.IO.TextReader textReader, Microsoft.Build.BuildEngine.ProjectLoadSettings projectLoadSettings);
member this.Load : System.IO.TextReader * Microsoft.Build.BuildEngine.ProjectLoadSettings -> unit
Public Sub Load (textReader As TextReader, projectLoadSettings As ProjectLoadSettings)
Parâmetros
- textReader
- TextReader
Um objeto TextReader que contém o conteúdo do projeto.A TextReader object containing the project contents.
- projectLoadSettings
- ProjectLoadSettings
Um valor ProjectLoadSettings que especifica as configurações do projeto que está sendo carregado.A ProjectLoadSettings value that specifies the settings for the project being loaded.
Aplica-se a
Load(TextReader)
Carrega o conteúdo do TextReader especificado para o objeto Project.Loads the contents of the specified TextReader into the Project object.
public:
void Load(System::IO::TextReader ^ textReader);
public void Load (System.IO.TextReader textReader);
member this.Load : System.IO.TextReader -> unit
Public Sub Load (textReader As TextReader)
Parâmetros
- textReader
- TextReader
O TextReader a ser carregado.The TextReader to load.
Exceções
O arquivo usado pelo textReaderTextReader não é um arquivo de projeto válido.The file used by the textReaderTextReader is not a valid project file.
Aplica-se a
Load(String)
public:
void Load(System::String ^ projectFileName);
public void Load (string projectFileName);
member this.Load : string -> unit
Public Sub Load (projectFileName As String)
Parâmetros
- projectFileName
- String
O arquivo de projeto a ser carregado.The project file to load.
Exceções
O arquivo especificado por projectFileName não é um arquivo de projeto válido.The file specified by projectFileName is not a valid project file.
Exemplos
O exemplo a seguir cria um Project objeto e usa BuildItem as BuildProperty classes,, e BuildItemGroup BuildPropertyGroup para listar todos os itens e propriedades no projeto.The following example creates a Project object and uses the BuildItem, BuildProperty, BuildItemGroup, and BuildPropertyGroup classes to list all the items and properties in the project.
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 the 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);
}
}
}
}
}
Module Module1
'You need to add references to Microsoft.Build.BuildEngine and
'Microsoft.Build.Framework
Sub Main()
'Set this to point to the location where the 2.0 clr/tools are installed
Engine.GlobalEngine.BinPath = "C:\windows\microsoft.net\framework\v2.0.xxxxx"
'Create a new empty project
Dim project As New Project()
'Load a project
project.Load("c:\temp\validate.proj")
'Output a header
Console.WriteLine("Project Properties")
Console.WriteLine("----------------------------------")
'Iterate through the various property groups and subsequently
'through the various properties
For Each propertyGroup As BuildPropertyGroup In project.PropertyGroups
For Each prop As BuildProperty In propertyGroup
Console.WriteLine("{0}:{1}", prop.Name, prop.Value)
Next
Next
Console.WriteLine()
Console.WriteLine("Project Items")
Console.WriteLine("----------------------------------")
'Iterate through the various itemgroups
'and subsequently through the items
For Each itemGroup As BuildItemGroup In project.ItemGroups
For Each item As BuildItem In itemGroup
Console.WriteLine("{0}:{1}", item.Name, item.Include)
Next
Next
End Sub
End Module