Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2010 如何使用生成后事件在TFS中签出复制签入文件?_Visual Studio 2010_Tfs_Post Build Event - Fatal编程技术网

Visual studio 2010 如何使用生成后事件在TFS中签出复制签入文件?

Visual studio 2010 如何使用生成后事件在TFS中签出复制签入文件?,visual-studio-2010,tfs,post-build-event,Visual Studio 2010,Tfs,Post Build Event,我有一个包含服务器控件的项目。每当我对它进行更改时,我希望能够在发布模式中生成,并将输出DLL(及其文档XML文件)复制到Team Foundation Server中的文件夹。 我提出了一个构建后事件: 检出DLL和XML 将它们复制到TFS文件夹 用一些注释将它们签回 以下是脚本: if $(ConfigurationName) == Release "$(DevEnvDir)tf" checkout /lock:none C:\CommonAssemblies\$(TargetFileNa

我有一个包含服务器控件的项目。每当我对它进行更改时,我希望能够在发布模式中生成,并将输出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.
    
    我偶然发现了答案

    /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."
    

    丢失的更改是否会导致构建失败,或者您只是收到了错误消息?文档()中没有显示可忽略此项的参数,但您可以在签入之前运行验证。查看VS2012()的文档时,force参数被描述为签入,即使没有任何更改。在VS2010中,这个参数已经存在,但在文档中没有描述,所以您可以尝试一下。@Mike它起作用了!/force参数似乎可以很好地完成这项工作。TKSFORCE参数是签入任何dll或exe时的一个好主意。看起来微软用来检测变化的算法并不是很好。我们遇到了这样一种情况:一个已经更改的二进制文件没有被签入,因为它已经足够接近了。这并不经常发生,但足以解决问题