如何结帐复制使用签生成后事件在TFS文件?(How to checkout-copy-checkin

2019-08-03 13:01发布

我有一个项目,拿着服务器控件。 每当我修改它,我希望能够在Release模式构建,并有复制到Team Foundation Server中的文件夹输出DLL(和它的文档XML文件)。

我已经拿出一个生成后事件:

  1. 检查DLL和XML列。
  2. 它们复制到文件夹TFS
  3. 检查他们回来与一些意见。

这是脚本:

if $(ConfigurationName) == Release "$(DevEnvDir)tf" checkout /lock:none C:\CommonAssemblies\$(TargetFileName)
if $(ConfigurationName) == Release "$(DevEnvDir)tf" checkout /lock:none C:\CommonAssemblies\$(TargetName).xml
if $(ConfigurationName) == Release copy $(TargetDir)$(TargetFileName) C:\CommonAssemblies\ /Y
if $(ConfigurationName) == Release copy $(TargetDir)$(TargetName).xml C:\CommonAssemblies\ /Y
if $(ConfigurationName) == Release "$(DevEnvDir)tf" checkin C:\CommonAssemblies\$(TargetFileName) /noprompt /comment:"File checked in automatically by Post-build action in source project."
if $(ConfigurationName) == Release "$(DevEnvDir)tf" checkin C:\CommonAssemblies\$(TargetName).xml /noprompt /comment:"File checked in automatically by Post-build action in source project."

这工作,但前提是在代码中的至少一个变化,在任何XML注释中的至少一个变化。 如果我尝试没有任何变化建立两次,我得到一个错误说:

The command "if Release == Re...... " exited with code 1.

我怎样才能摆脱这种错误的?

从输出窗口,我可以读取TFS检测到有文件中没有任何的变化,并撤消编辑。

我能添加到我的签入的指令会忽略掉这些签不发生变化的时候? 我一直工作至今与剧本,但我必须每次随机空间添加到代码和一些意见,它才能正常工作记忆。 必须有我丢失的东西,也许参数否则后果不堪设想。

下面是从输出窗口中的文本的一部分:

C:\CommonAssemblies:
  Controls.dll
C:\CommonAssemblies:
  Controls.xml
          1 file(s) copied.
          1 file(s) copied.
  C:\CommonAssemblies:
  Checking in edit: Controls.dll

  Changeset #6188 checked in.
  C:\CommonAssemblies:
  Checking in edit: Controls.xml

  The following changes were not checked in because the items were not modified.
    Undoing edit: C:\CommonAssemblies\Controls.xml

  There are no remaining changes to check in.

Answer 1:

我遇到了另一个类似的问题 ,我找到了答案。

/force参数什么是从签入指令失踪。 这将检查该文件中,即使有内没有检测到变化。

这个脚本不再引发错误:

if $(ConfigurationName) == Release "$(DevEnvDir)tf" checkout /lock:none C:\CommonAssemblies\$(TargetFileName)
if $(ConfigurationName) == Release "$(DevEnvDir)tf" checkout /lock:none C:\CommonAssemblies\$(TargetName).xml
if $(ConfigurationName) == Release copy $(TargetDir)$(TargetFileName) C:\CommonAssemblies\ /Y
if $(ConfigurationName) == Release copy $(TargetDir)$(TargetName).xml C:\CommonAssemblies\ /Y
if $(ConfigurationName) == Release "$(DevEnvDir)tf" checkin C:\CommonAssemblies\$(TargetFileName) /noprompt /force /comment:"File checked in automatically by Post-build action in source project."
if $(ConfigurationName) == Release "$(DevEnvDir)tf" checkin C:\CommonAssemblies\$(TargetName).xml /noprompt /force /comment:"File checked in automatically by Post-build action in source project."


文章来源: How to checkout-copy-checkin a file in TFS using Post-build event?