All Targets Not Being Called (nested Targets not being executed)

萝らか妹 提交于 2020-01-02 05:21:08

问题


I am using a two TARGET files. On one TARGET file I call a TARGET that is inside the second TARGET file. This second TARGET then calls another TARGET that has 6 other TARGET calls, which do a number of different things (in addition to calling other nested TARGETS (but inside the same TARGET file)). The problem is that, on the TARGET where I call 6 TARGETS, only the first one is being executed. The program doesnt find its way to call the 2nd, 3rd, 4th, 5th, and 6th TARGET. Is there a limit to the number of nested TARGETS that can be called and run? Nothing is failing. The problem is the other TARGET calls are not running. Thanks for any help you can provide.


回答1:


There is no limit to the number of targets nested. Have you tried running msbuild with all the log to see why the targets are not called :

msbuild [project.file] /verbosity:detailed 

I think this is due to unfulfilled condition (Condition attribute on target), unchanged input (Input attribute on target) or you are trying to call the same target multiples times.

Invoke the same target multiple times

  • Using MSBuild task :

    <!-- The target we want to execute multiple times -->
    <Target Name="VeryUsefulOne">
      <Message Text="Call VeryUsefulOne Target"/>
    </Target>
    
    <Target Name="One">
      <Message Text="One"/>
      <MSBuild Targets="VeryUsefulOne"
               Properties="stage=one" 
               Projects="$(MSBuildProjectFile)"/>
    </Target>
    
    <Target Name="Two">
      <Message Text="Two"/>
      <MSBuild Targets="VeryUsefulOne"
               Properties="stage=two" 
               Projects="$(MSBuildProjectFile)"/>
    </Target>
    
    <Target Name="OneTwo">
      <CallTarget Targets="One;Two"/>
    </Target>
    

It's important to change Properties value between call.



来源:https://stackoverflow.com/questions/2798762/all-targets-not-being-called-nested-targets-not-being-executed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!