4

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

我提出了一个构建后事件:

  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.
4

1 回答 1

7

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

/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."
于 2012-12-05T15:03:22.517 回答