首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >从MSBuild中的CallTarget调用的目标返回属性

从MSBuild中的CallTarget调用的目标返回属性
EN

Stack Overflow用户
提问于 2011-04-13 01:20:36
回答 1查看 1.7K关注 0票数 0

我是msbuild的新手,但即使使用谷歌,我也不知道如何从MSBuild中的CallTarget返回属性(见下文)。这是不可能的还是

代码语言:javascript
复制
   <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>  
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-04-13 05:29:16

更改此设置:

代码语言:javascript
复制
<Target Name="CheckDbStgExists"
  DependsOnTargets="CreateDbStgExistsProp">
  <CallTarget Targets="DBExists" />

要这样做:

代码语言:javascript
复制
<Target Name="CheckDbStgExists"
  DependsOnTargets="CreateDbStgExistsProp;DBExists">

当使用CallTarget执行目标时,创建的任何动态属性都将以不同于由于DependsOnTargets而运行的方式“发布”。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5639137

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档