방법: 솔루션 및 프로젝트 빌드 구성 만들기

업데이트: 2007년 11월

Visual Studio 자동화 모델은 솔루션 및 프로젝트 빌드 구성을 제어할 수 있는 개체를 제공합니다. 솔루션 빌드 구성에서는 솔루션에 있는 특정 프로젝트를 빌드하고 가능하다면 배포하는 방법을 지정합니다. 프로젝트 속성 페이지 대화 상자에 표시되는 프로젝트 빌드 구성에는 디버그 또는 릴리스와 같은 사용 가능한 프로젝트 빌드 형식과 .NET 또는 Win32와 같은 사용 가능한 플랫폼이 모두 나열됩니다. 플랫폼과 빌드가 조합되면 각 조합은 정의된 프로젝트 속성 및 설정 집합에 해당하는 하나의 프로젝트 구성을 형성합니다.

다음은 솔루션 빌드 구성 개체입니다.

개체 이름

설명

SolutionBuild2 개체

현재 활성 솔루션 구성을 빌드하고, 정리하고, 배포하는 데 사용됩니다.

SolutionConfiguration2 개체

빌드할 프로젝트 및 해당 구성 목록을 나타냅니다.

SolutionConfigurations 컬렉션

정의된 SolutionConfiguration 개체를 모두 포함합니다.

SolutionContext 개체

SolutionConfiguration 개체의 프로젝트 구성을 나타냅니다.

SolutionContexts 컬렉션

SolutionConfiguration 개체의 모든 SolutionContext 개체를 포함합니다.

BuildDependency 개체

소유하는 프로젝트를 빌드하기 전에 먼저 빌드되어야 하는 프로젝트를 나타냅니다.

BuildDependencies 컬렉션

소유하는 프로젝트를 빌드하기 전에 먼저 빌드되어야 하는 모든 프로젝트를 포함합니다.

다음은 프로젝트 빌드 구성 개체입니다.

개체 이름

설명

ConfigurationManager 개체

빌드 구성 및 플랫폼을 나타냅니다.

Configuration 개체

지정된 플랫폼 내의 구성 또는 빌드 설정 집합을 나타냅니다.

Configurations 컬렉션

모든 Configuration 개체를 포함합니다.

OutputGroup 개체

프로젝트에서 빌드된 파일을 포함합니다.

OutputGroups 컬렉션

모든 OutputGroup 개체를 포함합니다.

이러한 개체를 사용하여 다음 작업을 수행할 수 있습니다.

  • 솔루션 구성 만들기, 솔루션 구성에 프로젝트 추가, 솔루션 구성 활성화 및 삭제

  • 솔루션 구성에서 프로젝트 빌드, 실행 또는 배포

  • 프로젝트 또는 솔루션 구성 내의 개체에 대한 정보 가져오기

  • 프로젝트 빌드 종속성에 대한 정보 추가, 제거 또는 가져오기

참고:

표시되는 대화 상자와 메뉴 명령은 실제 설정이나 버전에 따라 도움말에서 설명하는 것과 다를 수 있습니다. 이러한 절차는 일반 개발 설정을 사용하여 개발되었습니다. 설정을 변경하려면 도구 메뉴에서 설정 가져오기 및 내보내기를 선택합니다. 자세한 내용은 Visual Studio 설정을 참조하십시오.

예제

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);
    }
}

코드 컴파일

이 코드를 컴파일하려면 새 Visual Studio 추가 기능 프로젝트를 만들고 Connect.cs 또는 Connect.vb 클래스의 코드를 예제에 있는 코드로 변경합니다. 추가 기능을 실행하기 전에 Visual Studio IDE에서 프로젝트를 엽니다. 추가 기능을 실행하는 방법에 대한 내용은 방법: 추가 기능 관리자를 사용하여 추가 기능 제어를 참조하십시오.

참고 항목

작업

방법: 명령 추가 및 처리

방법: 추가 기능 만들기

연습: 마법사 만들기

개념

솔루션, 프로젝트 및 항목 소개

자동화 개체 모델 차트

기타 리소스

Visual Studio에서 빌드

환경 창 만들기 및 제어

추가 기능 및 마법사 만들기

자동화 및 확장성 참조