0

私はmsbuildを初めて使用しますが、googleを使用しても、MSBuildのCallTargetからプロパティを返す方法がわかりません(以下を参照)。それは不可能ですか?

   <Target Name="CreateDbStgExistsProp">
   <!-- See http://stackoverflow.com/questions/1373162/passing-property-group-value-from-one-msbuild-task-to-another why this workaround is needed -->
   <PropertyGroup>
    <db>$(dbStg)</db>
    <machine>$(dwhdbStgmachine)</machine>
   </PropertyGroup>
  </Target>

  <Target Name="CheckDbStgExists" DependsOnTargets="CreateDbStgExistsProp">
   <CallTarget Targets="DBExists"/>
   <!-- this should pass the Property DoesDbExist for further reference created in Target DBExists, but it does not seem to work --> 
   <Message Text="Test: $(DoesDbExist)"/> 
  </Target>

  <Target Name="DBExists"   >
    <MSBuild.ExtensionPack.Sql2008.Database TaskAction="CheckExists" MachineName="$(machine)" DatabaseItem="$(db)" LogExceptionStack="true">
    <Output TaskParameter="Exists" PropertyName="DoesExist"/>
   </MSBuild.ExtensionPack.Sql2008.Database>
   <Message Text="Database $(db) does NOT exists" Condition="!$(DoesExist)"/>
   <Message Text="Database $(db) does exist" Condition="$(DoesExist)"/>
   <PropertyGroup>
     <DoesDbExist>$(DoesExist)</DoesDbExist>
   </PropertyGroup>

 </Target>  
4

1 に答える 1

0

これを変える:

<Target Name="CheckDbStgExists"
  DependsOnTargets="CreateDbStgExistsProp">
  <CallTarget Targets="DBExists" />

これに:

<Target Name="CheckDbStgExists"
  DependsOnTargets="CreateDbStgExistsProp;DBExists">

ターゲットが CallTarget で実行されると、作成されたすべての動的プロパティは、DependsOnTargets のために実行される場合とは異なる方法で「公開」されます。

于 2011-04-12T21:29:16.100 に答える