I'm trying to figure out how to close the loop in our build process where we apply a version number to the AssemblyInfo.* files as part of the build process.
We are in the midst of migrating from on-premise tfs to visual studio team services. Many of our current on-premise builds update the version number to keep it in sync with the build number and additionally check those files back into source control during the build.
I've successfully used the script located on msdn as an example to start customizing the build process.
I'm now attempting to check the files back into source control but I'm receiving the error:
#[error]TF30063: You are not authorized to access https://subdomain.visualstudio.com/DefaultCollection.
#[error]Process completed with exit code 100 and had 1 error(s) written to the error stream.
I'm currently using tf.exe to attempt to do this. First get the path to the tool at the top of the powershell script;
# get the tf command line tool path
$tfexe = [System.IO.Path]::GetFullPath($env:VS140COMNTOOLS + "..\..\common7\ide\tf.exe")
if (-Not (Test-Path $tfexe))
{
Write-Error "Could not find tf.exe at '$tfexe'"
exit 1
}
else
{
Write-Host "Found tf.exe at '$tfexe'"
}
Then modify the loop to checkout the file and then check the files back in.
# Apply the version to the assembly property files
$files = gci $Env:BUILD_SOURCESDIRECTORY -recurse -include "*Properties*","My Project" |
?{ $_.PSIsContainer } |
foreach { gci -Path $_.FullName -Recurse -include AssemblyInfo.* }
if($files)
{
Write-Host "Will apply $NewVersion to $($files.count) files."
foreach ($file in $files) {
#Write-Host "Attempting to checkout file '$file'"
& ($tfexe) vc checkout $file
$filecontent = Get-Content($file)
attrib $file -r
$filecontent -replace $VersionRegex, $NewVersion | Out-File $file
Write-Host "$file.FullName - version applied"
}
# Checkin pending changes together
##[error]TF30063: You are not authorized to access https://subdomain.visualstudio.com/DefaultCollection.
##[error]Process completed with exit code 100 and had 1 error(s) written to the error stream.
Write-Host "Attempting to checkin files"
$comment = "Applied $NewVersion to $($files.count) files. ***NO_CI***"
& ($tfexe) vc checkin /comment:"$comment" /noprompt
}
Is this the proper way to be doing this? If the build service is not authorized to access, how the heck can it GET the code, compile it, and then POST the artifact somewhere?
AssemblyInfo.*
files than check them into the source control. – Juan M. Elosegui Dec 28 '15 at 18:171.2.*
and have the build server apply the revision automagically, while manually controlling major and minor versions. – jessehouwing Dec 28 '15 at 20:12[assembly: AssemblyVersion("1.2.*")]
– jessehouwing Dec 28 '15 at 20:12