开发者

MSBuild SvnInfo - which Target Inputs are correct?

开发者 https://www.devze.com 2023-03-28 15:31 出处:网络
I use SvnInfo task in MSBuild script: <SvnInfo LocalPath=\"$(Sources)\"> <Output TaskParameter=\"Revision\" PropertyName=\"Revision\" />

I use SvnInfo task in MSBuild script:

<SvnInfo LocalPath="$(Sources)">
  <Output TaskParameter="Revision" PropertyName="Revision" />
</SvnInfo>

$(Sources) contains source files only.

Obviously SvnInfo depends on files in $(Sources). Target then uses info to generate output file with revision number.

In fact I want to run SvnInfo when revision number is changed, but not to run Target (use incremental build) when Revision number is the same as previous run.

How to specify correctly input in target (attribute Inputs in Target tag, which contains call of SvnInfo task)?

I made it in the following way:

<ItemGroup>
  <Target1Inputs Include="$(Sources)\**" />
</ItemGroup>

<Target Name="Target1" Inputs="@(Target1Inputs)" Outputs="...">
  ...
  <!-- SvnInfo call here -->
  <!-- File with revision number is created here -->

</Target>

It seems to me its workaround, because ideally I sho开发者_开发问答uld know which files SvnInfo depends on without guessing. Is it possible to obtain such info?

I am also not aware whether .svn folders are modified or not.


Basically in this way:

<PropertyGroup>
  <ExcludePdbs>$(YourOutputPath)\**\*.pdb</ExcludePdbs>
  <ExcludeTmp>$(YourOutputPath)\**\*tmp*</ExcludeTmp>
</PropertyGroup>

<!-- Prepare set of files -->
<ItemGroup>
   <Files Include="$(FilesToIncludeFolder)\**\*.*"
          Exclude="$(ExcludePdbs);$(ExcludeTmp);$(ExcludeOtherFiles);"/>
</ItemGroup>

<!-- Pass into the target -->
<Target Name="Target1" Inputs="@(Files)" Outputs="..." />

EDIT: The question was updated so here is my update as well

Supposing you can handle revision changed state, you can add Condition to a Target and run it depends on property $(RevisionWasChanged).

<Target Condition="$(RevisionWasChanged)=='True'"` />

Also to control build script execution flow you can use <Choose> feature:

<Choose>
    <When Condition="$(RevisionWasChanged)=='True'">
    </When>
    <Otherwise>
    </Otherwise>
</Choose>

Let me know whether it works for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号