我有一个持有服务器控件的Project。每当我对其进行更改时,我希望能够在发布模式下构建并将输出DLL(及其文档Xml文件)复制到Team Foundation Server中的文件夹中。
我已经提出了一个构建后的事件:
这是剧本:
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.
答案 0 :(得分:6)
我遇到了another similar question,我找到了答案。
/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."