CC.NET File merge task and dynamic values

情到浓时终转凉″ 提交于 2019-12-07 12:04:51

问题


How can I use CCNetLabel in the file merge task? From what I have found I have to use dynamicValues. I have something like this and it is not working any help?

<publishers>
  <merge>
    <dynamicValues>
      <replacementValue property="files">
        <format>D:\Testoutput\{0}\*.xml</format>
        <parameters>
          <namedValue name="$CCNetLabel" value="Default" />
        </parameters>
      </replacementValue>
    </dynamicValues>
  </merge>
  <xmllogger />
  <modificationHistory onlyLogWhenChangesFound="true" />
  <statistics />
</publishers>

回答1:


In your script you're trying to generate the following configuration (intentionally I'm using the shorthand notation which is easier to read):

<publishers>
  <merge>
    <files>D:\Testoutput\$[$CCNetLabel]\*.xml</files>
  </merge>
  <xmllogger />
  <modificationHistory onlyLogWhenChangesFound="true" />
  <statistics />
</publishers>

This won't work because <files> is an array, therefore you'd need something like:

<publishers>
  <merge>
    <files>
      <file>D:\Testoutput\$[$CCNetLabel]\*.xml</file>
    </files>
  </merge>
  <xmllogger />
  <modificationHistory onlyLogWhenChangesFound="true" />
  <statistics />
</publishers>

Unfortunately this doesn't work either because <dynamicValues> are supported only for the <merge> but not for the <files> tag. I don't think it's currently (version 1.6) possible to use integration properties here at all.

I'd use the following workaround to achieve the same result:

<publishers>
  <exec>
    <executable>C:\Windows\system32\cmd.exe</executable>
    <buildArgs>/C copy D:\Testoutput\$[$CCNetLabel]\*.xml D:\Testoutput\FixedDir</buildArgs>
  </exec>
  <merge>
    <files>
      <file>D:\Testoutput\FixedDir\*.xml</file>
    </files>
  </merge>
  <xmllogger />
  <modificationHistory onlyLogWhenChangesFound="true" />
  <statistics />
  <exec>
    <executable>C:\Windows\system32\cmd.exe</executable>
    <buildArgs>/C del D:\Testoutput\FixedDir\*.xml</buildArgs>
  </exec>
</publishers>


来源:https://stackoverflow.com/questions/4569614/cc-net-file-merge-task-and-dynamic-values

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