如何使用Post-build事件在TFS中签出复制签入文件?

alo*_*res 3 tfs visual-studio-2010 post-build-event

我有一个项目持有服务器控件.每当我对它进行更改时,我希望能够在Release模式下构建并将输出DLL(及其文档Xml文件)复制到Team Foundation Server中的文件夹中.

我发布了一个post-build事件:

  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."
Run Code Online (Sandbox Code Playgroud)

这是有效的,但前提是代码中至少有一个更改,并且任何XML注释中至少有一个更改.如果我尝试构建两次而没有任何更改,我会收到错误消息:

The command "if Release == Re...... " exited with code 1.
Run Code Online (Sandbox Code Playgroud)

我怎样才能摆脱这个错误?

在"输出"窗口中,我可以读到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.
Run Code Online (Sandbox Code Playgroud)

alo*_*res 6

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

/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."
Run Code Online (Sandbox Code Playgroud)