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

これは機能しますが、コードに少なくとも 1 つの変更があり、いずれかの XML コメントに少なくとも 1 つの変更がある場合に限ります。何も変更せずに 2 回ビルドしようとすると、次のようなエラーが表示されます。

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 に答える