2013-08-19 1 views
3

목록의 각 고객에 대해 프로젝트를 한 번 배포하기 위해 MSBuild 스크립트 중 하나에서 일괄 처리를 사용하기 시작했습니다. 모든 것이 계획대로 진행되는 것처럼 보였지만 이상한 문제가 발견되었습니다. 각 반복 작업이 끝날 때마다 작업은 MSI 파일의 사본을 만들어 고객 별 디렉토리에 저장하고, 특정 파일 이름. MSI 파일에 적절한 이름이 지정되지만 MSI 파일은 모두 동일한 폴더 ("Customer2"에 속함)로 복사됩니다.동일한 반복 내에서 MSBuild 일괄 처리 반복 반복 자

빌드 로그를 보면 복사 작업이 모두 빌드가 끝날 때 수행된다는 것을 알 수 있습니다. 왜 이런 일이 일어 났는지 설명 할 수 있습니까? 내가 원하는 것은 다음 고객에게 진행하기 전에 전체 "배포"대상을 실행하는 것입니다.

다음은 MSBuild 코드입니다.

<PropertyGroup> 
    <Customers>Customer1;Customer2</Customers> 
    </PropertyGroup> 

    <ItemGroup> 
    <Customer Include="$(Customers)"/> 
    </ItemGroup> 

    <Target Name="Deploy"> 

    <PropertyGroup> 
     <DeploymentDirectory>$(Root)MyApplication_%(Customer.Identity)_ci</DeploymentDirectory> 
     <SolutionDir>../MyApplication</SolutionDir> 
     <ProjectFile>$(SolutionDir)/MyApplication/MyApplication.csproj</ProjectFile> 
    </PropertyGroup> 

    <MSBuild Projects="web_application_deploy.msbuild" Properties=" 
      ProjectFile=$(ProjectFile); 
      SolutionFile=$(SolutionDir)\MyApplication.sln; 
      AppName=MyApplication_%(Customer.Identity)_ci; 
      TestDll=$(SolutionDir)/MyApplication.Tests/bin/Release/MyApplication.Tests.dll" /> 


    <!-- Build WIX project--> 
    <MSBuild Condition="$(BuildWix) == true" 
      Projects="$(SolutionDir)\MyApplication.Wix\MyApplication.Wix.wixproj" 
      Properties="DeploymentDirectory=$(DeploymentDirectory);VersionNumber=$(BUILD_NUMBER)" /> 

    <!-- Copying the installer file to correct path, and renaming with version number --> 
    <Exec Condition="$(BuildWix) == true" 
      Command="copy &quot;$(SolutionDir)\MyApplication.Wix\bin\$(Configuration)\MyApplication.msi&quot; &quot;$(DeploymentDirectory)\MyApplication-%(Customer.Identity)-v$(BUILD_NUMBER).MSI&quot;"></Exec> 
    </Target> 

업데이트 : 나는 관련성이 안되는 일을 냈다 한 나는 "Exec에서"호출에서 $(DeploymentDirectory) 속성을 사용하는 대신 직접 반복자 %(Customer.Identity)를 참조하는 경우 작동합니다. 이처럼 :

<Exec Condition="$(BuildWix) == true" 
      Command="copy &quot;$(SolutionDir)\DataGateway.Wix\bin\$(Configuration)\DataGateway.msi&quot; &quot;$(CiRoot)DataGateway_%(Customer.Identity)_ci\DataGateway-%(Customer.Identity)-v$(BUILD_NUMBER).MSI&quot;"></Exec> 

는 그래서이 참조 할 때 올바른 고객과 업데이트되지 않습니다 "DeploymentDirectory"라는 특성처럼 보인다. 루프의 각 반복에서 해당 속성이 "새로 고침"되었는지 확인할 수있는 다른 방법이 있습니까?

답변

3

는 생각이처럼 일을 뭔가 :

<Target Name="DeployNotBatching" > 
     <Message Text="Deployment to server done here. Deploying to server: %(Customer.Identity)" /> 
     <Message Text="Also called" /> 

</Target> 

제공 :

Deployment to server done here. Deploying to server: Customer1 
    Deployment to server done here. Deploying to server: Customer2 
    Also called 

당신이 정말로이 작업을 수행 할 수?

결과 그건
<Target Name="Deploy" Inputs="@(Customer)" Outputs="%(Identity)"> 
     <Message Text="Deployment to server done here. Deploying to server: %(Customer.Identity)" /> 
     <Message Text="Also called" /> 

</Target> 

:

Deploy: 
    Deployment to server done here. Deploying to server: Customer1 
    Also called 
Deploy: 
    Deployment to server done here. Deploying to server: Customer2 
    Also called 

가 그래서 전체 대상 개별 명령보다는 반복된다?

+0

예, 감사합니다.이 문제를 해결해 주셔서 감사합니다 :) 나는 배치 작업이 어떻게 작동하는지 조금 혼란스럽게 생각합니다. 입력/출력이 빠진 부분이었습니다! –