Using TFS TF History to Determine the Latest Change Set

I am writing a script that will run the assembly only if the source code changes. I need to know if a change has occurred since the assembly started. This worked because the folder was not deleted, so it was easy to determine if there was a change, but now everything is deleted every time the build is performed. I thought about using the TFS TF history command to query the last change set or the last two change sets, but there was a problem parsing only the change set number from the output. I also considered using the changeet command. Is there any command line parameter that I can use to answer the question, has there been a change from the date or number of the change set?

+3
source share
6 answers

excerpt from my build batch file.

set _aPath="f:\TFS\a"
set _TFPath="c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE"

...

pushd %_aPath%
%_TFPath%\TF.exe history . /r /noprompt /stopafter:1 /Version:W > temp
FOR /f "tokens=1" %%a in ('findstr /R "^[0-9][0-9]*" temp') do set _BuildVersion=10.3.0.%%a
del temp
popd

uses a temporary file but works well.

+3
source

To the last change set number without a local workspace, use the following command:

tf history /collection:"http://server:8080/tfs/Collection" "$/Project" /recursive /stopafter:1 /noprompt /login:domain\user,password
+3
source

, TFS . , , , . :

tf history <folder> /version:C<changeset>~T /noprompt /recursive

- , , , , . , .

+2

, BuildForge Microsoft Team Foundation Server. URL, ... http://www-304.ibm.com/partnerworld/gsd/solutiondetails.do?&solution=46360&lc=en

Automatra TFS Rational Build Forge (CI) .

TFS CI TFS (Change Set), WorkItem. (BOM), .

, , , , Build Forge - ( ). , , , , .

+1

:

for /f "usebackq tokens=*" %%a in (`tf history . /recursive /noprompt /stopafter:1 /version:T ^| powershell -Command "$input | ? { $_ -imatch '^(\d+)\s+' } | %% { $matches[0].Trim() } | Select-Object -First 1"`) do set TIP_CHANGESET=%%a

TIP_CHANGESET env.

+1

My PowerShell script, GetVcsRevision.ps1 VCS Root:

param (
    [string]$PathToTF='C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\TF.exe'
    ,[Parameter(Mandatory=$true)][string]$Login
    ,[Parameter(Mandatory=$true)][string]$Password
)
$result = &$PathToTF @("history","/stopafter:1","/recursive","..\*","/login:""$Login"",""$Password""") 2>&1 3>&1

if ($result.GetType().Name -eq "Object[]")
{
    <# $result format is:
        Changeset User              Date       Comment
        --------- ----------------- ---------- ----------------------------------------
        26038     user              24.06.2014 Sample commit comment

        $result[2] is:
        26038     user              24.06.2014 Sample commit comment

        $result[2].Split(" ")[0] is:
        26038
    #>

    $result[2].Split(" ")[0]
}
else
{
    "0"
}

. - , 0.

script script.

0