Freigeben über


SolutionBuild2.BuildProject-Methode (String, String, Boolean)

Erstellt das angegebene Projekt und die zugeordneten Abhängigkeiten im Kontext der angegebenen Projektmappenkonfiguration.

Namespace:  EnvDTE80
Assembly:  EnvDTE80 (in EnvDTE80.dll)

Syntax

'Declaration
Sub BuildProject ( _
    SolutionConfiguration As String, _
    ProjectUniqueName As String, _
    WaitForBuildToFinish As Boolean _
)
void BuildProject(
    string SolutionConfiguration,
    string ProjectUniqueName,
    bool WaitForBuildToFinish
)
void BuildProject(
    String^ SolutionConfiguration, 
    String^ ProjectUniqueName, 
    bool WaitForBuildToFinish
)
abstract BuildProject : 
        SolutionConfiguration:string * 
        ProjectUniqueName:string * 
        WaitForBuildToFinish:bool -> unit 
function BuildProject(
    SolutionConfiguration : String, 
    ProjectUniqueName : String, 
    WaitForBuildToFinish : boolean
)

Parameter

  • SolutionConfiguration
    Typ: System.String
    Erforderlich.Der Name der neuen Projektmappenkonfiguration, die den Kontext für die Projekterstellung zur Verfügung stellt.
  • ProjectUniqueName
    Typ: System.String
    Erforderlich.Das zu erstellende Projekt.
  • WaitForBuildToFinish
    Typ: System.Boolean
    Optional.Bestimmt, ob der Abschluss des Buildvorgangs abgewartet werden soll.Wenn true, wird gewartet, andernfalls nicht.

Hinweise

BuildProject wird sofort zurückgegeben.Sie müssen das OnBuildDone-Ereignis überprüfen, um zu bestimmen, ob der Projektmappen-Buildvorgang abgeschlossen ist.

BuildProject bewirkt keine Änderung der aktiven Projektmappenkonfiguration bzw. des ausgewählten Projekts und hat in diesem Sinne keine Auswirkungen auf die Benutzeroberfläche.Wenn Sie das Projekt relativ zu der aktiven Projektmappenkonfiguration erstellen möchten, verwenden Sie DTE.SolutionBuild.ActiveConfiguration.Name.

BuildProject betrifft die Benutzeroberfläche jedoch insofern, als dass je nach DTE.SuppressUI-Flag die Statusleiste flimmert und das Ausgabefenster sowie die Aufgabenliste stets aktualisiert werden.

BuildProject erstellt das angegebene Projekt und alle seine Abhängigkeiten, die daraufhin überprüft werden, ob sie in der angegebenen Projektmappenkonfiguration erstellt wurden.

Beispiele

In diesem Beispiel wird ein Projekt im Debugmodus erstellt.Öffnen Sie vor dem Ausführen des Add-Ins in der integrierten Entwicklungsumgebung (Integrated Development Environment – IDE) von Visual Studio ein Projekt.

Weitere Informationen zum Ausführen dieses Beispiels als Add-In finden Sie unter Gewusst wie: Kompilieren und Ausführen der Codebeispiele für das Automatisierungsobjektmodell.

Imports EnvDTE
Imports EnvDTE80
Public Sub OnConnection(ByVal application As Object, _
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    _applicationObject = CType(application, DTE2)
    _addInInstance = CType(addInInst, AddIn)
    SolutionBuildProjectExample(_applicationObject)
End Sub
Sub SolutionBuildProjectExample(ByVal dte As DTE2)
    ' Open a solution in Visual Studio before running this example.
    Try
        Dim soln As Solution2 = CType(_applicationObject.Solution, _
        Solution2)
        Dim sb As SolutionBuild2
        Dim bld As BuildDependencies
        Dim p1 As Project = soln.Projects.Item(1)
        sb = CType(soln.SolutionBuild, SolutionBuild2)
        bld = sb.BuildDependencies
        MsgBox("The project " & bld.Item(1).Project.Name & " has "  _
        & bld.Count.ToString() & " build dependencies.")
        MsgBox("Building the project in debug mode...")
        sb.BuildProject("Debug", p1.FullName, True)
    Catch ex As System.Exception
        MsgBox(ex.ToString)
    End Try
End Sub
using EnvDTE;
using EnvDTE80;
using System.Windows.Forms;
public void OnConnection(object application,
 ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    SolutionBuildProjectExample(_applicationObject);
}
public void SolutionBuildProjectExample(DTE2 dte)
{
    try
    {
        Solution2 soln = (Solution2)_applicationObject.Solution;
        SolutionBuild2 sb;
        BuildDependencies bld;
        Project p1 = soln.Projects.Item(1);
        // Open a solution in Visual Studio before 
        // running this example.
        sb = (SolutionBuild2)soln.SolutionBuild;
        bld = sb.BuildDependencies;
        MessageBox.Show("The project " + bld.Item(1).Project.Name 
+ " has " + bld.Count.ToString() + " build dependencies.");
        MessageBox.Show("Building the project in debug mode...");
        sb.BuildProject("Debug", p1.FullName,true);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework-Sicherheit

Siehe auch

Referenz

SolutionBuild2 Schnittstelle

BuildProject-Überladung

EnvDTE80-Namespace