Pergunta

I have a Project holding server controls. Whenever I make changes to it I want to be able to Build in Release mode and have the output DLL (and its documentation Xml file) copied to a folder in Team Foundation Server.

I have come out with a post-build event that:

  1. Checks both DLL and XML out.
  2. Copies them to the TFS folder
  3. Checks them back in with some comments.

This is the script:

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

This works, but only if there is at least one change in the code, and at least one change in any of the XML comments. If I try to build twice without any change, I get an error saying:

The command "if Release == Re...... " exited with code 1.

How can I get rid of this error?

From the Output window, I can read that TFS detected there were no changes in the file and it Undo the edit.

What can I add to my checkin instruction to ignore such checkin when no change is detected? I've been working so far with that script, but I must remember each time to add a random space to the code and to some comment for it to work properly. There must be something I'm missing, maybe a parameter or else.

Here's part of the text from the Output window:

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.
Foi útil?

Solução

I came across another similar question and I found the answer.

The /force parameter is what was missing from the checkin instruction. This checks in the file even when there are no detected changes within.

This script is no longer throwing errors:

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."
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top