하나의 MSBuild 스크립트에서 여러 MSBuild 스크립트를 호출하는 방법

StackOverflow https://stackoverflow.com/questions/1213228

  •  06-07-2019
  •  | 
  •  

문제

배포를위한 3 개의 MSBuild 스크립트가 있으며, 두 개의 웹 서비스를 배포하기 위해 UI 1을 배포하는 경우 1 개가 있습니다. 1 백엔드 서비스 배포의 경우 1.

이제 TeamCity 서버에서 실행할 수있는 위의 3 개의 스크립트를 모두 호출하는 한 번의 클릭 배포 MSBuild 스크립트를 작성하고 싶습니다.

따라서 다른 MSBuild 스크립트 에서이 세 가지 MSBuild 스크립트를 어떻게 호출 할 수 있습니까?

도움이 되었습니까?

해결책

다른 팁

TeamCity 서버를 사용하지 않았지만 가능한 대안 솔루션 중 하나는 세 빌드 스크립트를 하나의 스크립트로 결합하는 것입니다. 마스터 빌드 파일의 세 가지 스크립트의 작업을 별도의 대상에 넣습니다. 따라서 세 개의 개별 빌드 스크립트 대신 3 개의 대상, 즉 deployui, deployservices, deploybackend가있는 1 개의 빌드 스크립트가 있습니다. 아래에 테스트되지 않은 샘플 :

    <?xml version="1.0" encoding="utf-8" ?>
    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="DefaultTarget" ToolsVersion="3.5">

    <Target Name="DefaultTarget">
            <CallTarget Targets="deployUI" ContinueOnError="false"></CallTarget>
            <CallTarget Targets="deployServices" ContinueOnError="false"></CallTarget>
            <CallTarget Targets="deployBackend" ContinueOnError="false"></CallTarget> 
    </Target>

    <Target Name="deployUI">
            <!-- Put UI deployment tasks here -->
    </Target>

    <Target Name="deployServices">
            <!-- Put Services deployment tasks here -->
    </Target>

    <Target Name="deployBackend">
            <!-- Put Backend deployment tasks here -->
    </Target>
</Project>

MSBuild 4.0에서는 옵션이있을 수 있습니다 조건부 수입 하나의 클릭 배포 MSBUILD 스크립트에 3 개의 프로젝트 파일을 파일 :

<Import Project="ProjectPath1" Condition="'$(DeployUI)'!=''" />
<Import Project="ProjectPath2" Condition="'$(DeployWebServices)'!=''" />
<Import Project="ProjectPath3" Condition="'$(DeployBackendServices)'!=''" />

<Target Name="DeployTheWorld">
    <Message Text="Deploying..." />
</Target>

그런 다음 사용하십시오 AfterTargets 기능 가져온 별도의 프로젝트 파일에서 실행하려는 대상에서 :

  <Target Name="DeployUI" AfterTargets="DeployTheWorld">
    <Message Text="Hello from DefaultAfterTarget"/>
  </Target>

이렇게하면 TeamCity 내에서 배포를 사용자 정의 할 수 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top