2011-04-12 12 views
0

MSBuildの新機能ですが、Googleの場合でもMSBuildのCallTargetからプロパティを返す方法はありません(下記参照)。これにMSBuildのCallTargetによって呼び出されたターゲットのプロパティを返します。

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

:ターゲットがCallTargetで実行された場合

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

、作成した任意の動的特性がに "公表" されていない可能性や

<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> 

答えて

0

変更するには、このことですDependsOnTargetsのために実行される場合とは異なる方法です。

+0

完璧、まさに私が必要としたもの。 – dim

関連する問題