我有一个持有服务器控件的项目。每当我对其进行更改时,我都希望能够在发布模式下构建并将输出 DLL(及其文档 Xml 文件)复制到 Team Foundation Server 中的文件夹中。
我提出了一个构建后事件:
- 检查 DLL 和 XML。
- 将它们复制到 TFS 文件夹
- 用一些评论重新检查它们。
这是脚本:
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.