Aracılığıyla paylaş


Nasıl yapılır: çözüm ve proje yapı yapılandırmaları oluşturmak

Visual Studio , Yapý yapýlandýrmasýný proje ve çözüm denetleme sağlayan nesneleri otomasyon modeli sunar.Nasıl belirli bir çözüm içindeki projelerdir çözüm yapý yapýlandýrmasý belirtir yerleşik ve etkin, dağıtılabilir.Listelenen yapý yapýlandýrmasýný proje Projenin Property Pages iletişim kutusu, kullanılabilir tüm proje türleri oluşturur, hata ayıklama veya sürüm ve kullanılabilir platformları gibi gibi liste.net veya Win32.Yapı ve platform her birleşim için bir proje yapýlandýrmasý vardır — tanımlı proje özellikleri ve ayarları kümesi.

Çözüm oluşturma yapılandırma nesneler şunlardır:

Nesne adı

Description

SolutionBuild2Nesne

Yapı, temiz ve etkin çözüm yapýlandýrmasý dağıtmak için kullanılır.

SolutionConfiguration2Nesne

Projeler ve oluşturulacak olan yapılandırmalarına listesini gösterir.

SolutionConfigurationskoleksiyonu

İçeren tüm tanımlı SolutionConfiguration nesneler.

SolutionContextNesne

Bir projenin yapılandırmasını temsil eden bir SolutionConfiguration nesne.

SolutionContextskoleksiyonu

Tüm içeren SolutionContext veritabanındaki nesneler bir SolutionConfiguration nesne.

BuildDependencyNesne

Sahibi olan proje oluşturulmadan önce oluþturulmasý gereken bir proje temsil eder.

BuildDependencieskoleksiyonu

Sahibi olan proje oluşturulmadan önce oluşturulmalıdır tüm projeleri içerir.

Proje yapı yapılandırma nesneler şunlardır:

Nesne adı

Description

ConfigurationManagerNesne

Yapılandırma ve platformlarda temsil oluşturun.

ConfigurationNesne

Bir yapılandırma veya içinde belirtilen bir platform oluşturma ayarları kümesini temsil eder.

Configurationskoleksiyonu

Tüm içeren Configuration nesneler.

OutputGroupNesne

Project tarafından oluşturulan dosyaları içerir.

OutputGroupskoleksiyonu

Tüm içeren OutputGroup nesneler.

Bu nesneleri kullanarak şunları yapabilirsiniz:

  • Oluşturma, etkinleştirmek için projeler ekleyin ve çözüm yapýlandýrmalarý silin.

  • Yapı, çalıştırmak veya herhangi bir projede bir çözüm yapýlandýrmasýný dağıtma.

  • Bir proje veya çözüm yapılandırması içindeki nesneler hakkında bilgi edinin.

  • Ekler, kaldırır veya proje yapı bağımlılıkları hakkında bilgi edinin.

[!NOT]

Gördüğünüz iletişim kutuları ve menü komutları, etkin ayarlarınıza ve ürün sürümüne bağlı olarak Yardım menüsünde açıklanana göre farklılık gösterebilir.Bu yordamlar, genel geliştirme ayarları ile etkin geliştirilmiştir.Ayarlarınızı değiştirmek için Al ve Verayarları üzerinde araçları menü.Daha fazla bilgi için bkz. Visual Studio ayarları.

Örnek

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)
    SConfig(_applicationObject)
End Sub
Sub SConfig(ByVal dte As DTE2)
    Dim SB As SolutionBuild2 =  _
    CType(_applicationObject.Solution.SolutionBuild, _
    SolutionBuild2)
    Dim SolCtx As SolutionContext
    Dim Proj As Project
    Dim CM As ConfigurationManager
    Dim Cfgs As SolutionConfigurations
    Dim Cfg As SolutionConfiguration2
    Dim msg As String

    ' Get a reference to the solution configurations 
    ' solution context of the first project.
    SolCtx = SB.SolutionConfigurations.Item(1).SolutionContexts.Item(1)
   CM = _applicationObject.Solution.Projects. _
    Item(1).ConfigurationManager
    Proj = _applicationObject.Solution.Projects.Item(1)
    Cfgs = _applicationObject.Solution.SolutionBuild. _
    SolutionConfigurations
    Cfg = CType(Cfgs.Item(1), SolutionConfiguration2)

    ' List the current solution build info.
    msg = "BuildState = "
    Select Case SB.BuildState
        Case vsBuildState.vsBuildStateNotStarted
            msg = msg & "Build has not yet started." & vbCr
        Case vsBuildState.vsBuildStateInProgress
            msg = msg & "Build is in progress." & vbCr
        Case vsBuildState.vsBuildStateDone
            msg = msg & "Build has completed." & vbCr
    End Select
    msg = msg & "Configuration Name = " & SolCtx.ConfigurationName _
    & vbCr
    msg = msg & "Platform Name = " & SolCtx.PlatformName & vbCr
    msg = msg & "Project Name = " & SolCtx.ProjectName & vbCr
    MsgBox(msg)

    ' List the current solution configurations.
    msg = ("Configuration names are:" & vbCr)
    For Each Cfg In Cfgs
        msg = msg & Cfg.Name & vbCr
    Next
    MsgBox(msg)
   ' Add a new solution configuration.
   Cfgs.Add("ANewConfiguration", "Debug", False)
   MsgBox(Cfgs.Item(1).Name)
   ' Create a new project build configuration based on the Debug 
   ' configuration.
   Proj.ConfigurationManager.AddConfigurationRow("MyNewConfig", _
    "Debug", True)
   ' Build the solution configuration.
   sb.SolutionConfigurations.Item("MyConfig").Activate()
   sb.Build()
End Sub
public void OnConnection(object application, 
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    SConfig(_applicationObject);
}
public void SConfig(DTE2 dte)
{
    try
    {
        SolutionBuild2 SB =
 (SolutionBuild2)_applicationObject.Solution.SolutionBuild;
        SolutionContext SolCtx;
        Project Proj;
        ConfigurationManager CM;
        SolutionConfigurations Cfgs;
        SolutionConfiguration2 Cfg;
        String msg;
        // Get a reference to the solution configurations
        // solution context of the first project.
        SolCtx = SB.SolutionConfigurations.Item(1).
SolutionContexts.Item(1);
        CM = dte.Solution.Projects.Item(1).ConfigurationManager;
        Proj = _applicationObject.Solution.Projects.Item(1);
        Cfgs = _applicationObject.Solution.
SolutionBuild.SolutionConfigurations;
        Cfg = (SolutionConfiguration2)Cfgs.Item(1);
        // List the current solution build info.
        msg = "BuildState = ";
        switch (SB.BuildState)
        {
            case vsBuildState.vsBuildStateNotStarted:
                msg = (msg + "Build has not yet started." + "\n");
            break;
            case vsBuildState.vsBuildStateInProgress:
                msg = (msg + "Build is in progress." + "\n");
            break;
            case vsBuildState.vsBuildStateDone:
                msg = (msg + "Build has completed." + "\n");
            break;
        }
        msg = msg + "Configuration Name = " + 
SolCtx.ConfigurationName + "\n";
        msg = msg + "Platform Name = " + SolCtx.PlatformName + "\n";
        msg = msg + "Project Name = " + SolCtx.ProjectName + "\n";
        MessageBox.Show(msg);
        // List the current solution configurations.
        msg = "Configuration names are:" + "\n";
        foreach(SolutionConfiguration2 tempConfigs in Cfgs)
        {
            msg = msg + tempConfigs.Name + "\n";
        }
        MessageBox.Show(msg);
        // Add a new solution configuration.
        Cfgs.Add("ANewConfiguration", "Debug", false);
        MessageBox.Show
("The name of the first solution configuration item is: " 
+ Cfgs.Item(1).Name);
        // Create a new project build configuration based on the 
        // Debug configuration.
        Proj.ConfigurationManager.AddConfigurationRow
("MyNewConfig", "Debug", true);
        // Build the debug solution configuration.
        MessageBox.Show("Build the solution in the debug mode...");
        SB.SolutionConfigurations.Item("Debug").Activate();
        SB.Build(true);
    }
    catch (Exception ex)
    {
        MessageBox.Show("Exception: " + ex);
    }
}

Kod Derleniyor

Bu kodu derlemeye yeni bir oluşturmak Visual Studio eklenti projesi ve örnek kodda Connect.cs veya Connect.vb sınıf koduyla Değiştir.Eklenti çalıştırmadan önce bir proje açın Visual Studio IDE.Bir eklenti çalıştırma hakkında daha fazla bilgi için bkz: Nasıl yapılır: denetim Eklenti Yöneticisi'ni kullanarak eklentileri.

Ayrıca bkz.

Görevler

Nasıl yapılır: ekleme ve komutları işlemek

Nasıl yapılır: bir eklenti oluşturmak

İzlenecek yol: bir sihirbaz oluşturma

Kavramlar

Çözüm ve proje temelleri

Otomasyon nesne modeli şeması

Diğer Kaynaklar

Visual Studio'da Uygulama Oluşturma

Oluşturma ve ortam Windows denetleme

Eklentiler ve sihirbazlar oluşturma

Otomasyon ve Genişletilebilirlik Başvurusu