We use a nice $(date:yyyy.MM.dd)$(rev:.r) build number format in our day-to-day agile sprints. However, the release must be numbered with a simpler 1.0.0.rev schema.
Ideally, I would like to give the build number as a variable, which would be automatically expanded in the "queue build" dialog, where it would be possible to be overriden. How can it be done?
I tried moving the $(date:yyyy.MM.dd)$(rev:.r) format to a variable, and use that variable in the general tab, and got error 400.
You could directly use Environment variables such as Build.BuildNumber /BUILD_BUILDNUMBER
Using this just equals to the name of the completed build. You can specify the build number format that generates this value on the General tab.
If you just want to generate custom build numbers like 1.0.0.rev schema in TFS Build vNext. You can take a look at below blogs:
Generate custom build numbers in TFS Build vNext
Managing vNext build Version Numbers
This is very simple.
1) Just create a Powershell script like this
$FinalVersion=Some-Function-To-Calculate-Version
$BuildDefName = $Env:BUILD_DEFINITIONNAME
Write-Host "##vso[build.updatebuildnumber]$($BuildDefName)-$($FinalVersion)"
2) In your vNext build definition, for "Build number format" just set it to anything. It doesn't matter because the Build Number will be overwritten.
3) In the same vNext build definition steps, add the first step as a Powershell step, and set your script from step 1 to be executed. You can later customize if you want to pass variables in order to calculate your build number.
4) Queue your build and see the results.
Related
According to my post:
Build Definition XAML -> TFS2015
which is duplicated with:
How to handle multiple configurations in VSTS Release management?
I have one more question about Build Proces in TFS 2015. can someone tell me how can I set two outputs path after build? I mean one for x64 bit and second for x32 bit during one build process?
../Release/x64/..
../Release/x32/..
Build Platform is set to "MixedPlatform". I did try also with "Any CPU" without result...
My configuration is in the first link.
I'm assuming you have a multiplier set up on the BuildConfiguration or BuildPlatform variables, or on both, so that the build process runs multiple times for each permutation.
In that case, you just need to override your output path (usually /p:OutDir=(some path)). In this case, you'd override it to $(Build.ArtifactStagingDirectory)\$(BuildConfiguration)\$(BuildPlatform). That will put the outputs for the current permutation of your build to a specific folder for that permutation.
Then, in your publish artifacts task, make sure you're publishing an artifact pointing to $(Build.ArtifactStagingDirectory)\$(BuildConfiguration)\$(BuildPlatform) with a unique name, like Web_$(BuildConfiguration)-$(BuildPlatform)
Then, when the builds are all done, you'll have multiple sets of artifacts attached to the build, one for each permutation. You can then consume those artifacts down-stream in a release definition.
Can we demonstrate where the release number increase and stays in sequence when we use TFS (example 1, 1.1, 1.2, 1.3, etc) and that when we do a build in Visual Studio the number in TFS will skip ahead by 1 (example – TFS build 1, 1.1, 1.2, build in Visual Studio, then do another build in TFS – the next number in TFS would be 1.4). This is for TFS 2015.
If you want to change the default increase mechanism in build number format. Unfortunately, it's impossible.$(Rev:.rr) Its start by one.
What is $(Rev:.rr)?
To ensure that every completed build has a unique name. When a build
is completed, if nothing else in the build number has changed, the Rev
integer value is incremented by one.
Source:MSDN
If you just want to override your Build number with variables, follow below steps:
Create a Powershell script like this:
$FinalVersion=Some-Function-To-Calculate-Version
$BuildDefName = $Env:BUILD_DEFINITIONNAME
Write-Host "##vso[build.updatebuildnumber]$($BuildDefName)-$($FinalVersion)"
In your vNext build definition, for "Build number format" you could set
it to anything, cause the Build Number will be
overwritten.
In the same vNext build definition steps, add the first step as a
Powershell step, and set your script from step 1 to be executed.
You can later customize if you want to pass variables in order to
calculate your build number.
Queue your build .
This is using the logging commands to set the build number.
In Team City, there is the concept of a build counter. The counter is incremented each time a build is performed and is scoped to a single build definition - so invoking build definition A will not update the counter for build definition B and vice-versa.
In Visual Studio Team Services (was Visual Studio Online) build, there is a $Env:BUILD_BUILDNUMBER but this number seems to be scoped globally to all build definitions.
In order to label my builds and the subsequent nuget packages using the semver major.minor.patch I would like access to a teamcity like build counter, scoped to a single build definition.
I'd rather not use a script to update some file or http based per build store, which feels like a lot of work for something which is so simple out of the box in Team City.
You can update "Build number format" under "General" tab in your build definition settings to use "$(Rev:.r)" as the build number like following:
major.minor$(Rev:.r)
Use $(Rev:.rr) to ensure that every completed build has a unique name.
When a build is completed, if nothing else in the build number has
changed, the Rev integer value is incremented by one.
If you want to show prefix zeros in the number, you can add additional
r characters. For example, specify $(rev:.rr) if you want the Rev
number to begin with 01, 02, and so on.
Refer to this link for details: Build Number Format.
I have a Build Definition to build a solution on my TFS.
This works well, but it always builds the latest version.
How can I force to build a specific changeset from the past?
How can I use/pass this number to the "MSBuild Arguments" to use it there for deployment?
When you queue up the build from Team Explorer, in the Parameters tab one of the Advanced arguments is get version.
Note: I think you need to specify this in the form C123 where 123 is the changeset number.
The answer to your first question is clearly what #Dylan has stated.
To your second part:
The important argument is GetVersion.
Navigate to activity "Run MSBuild for Project" within your Build Process Template, by default this has a value CommandLineArguments equal to
String.Format("/p:SkipInvalidConfigurations=true {0}", MSBuildArguments)
You can change it to something like
String.Format("/p:SkipInvalidConfigurations=true {0} /p:DeployIisAppPath=/changeset/{1}", MSBuildArguments, GetVersion)
and get where you need to go.
If you use the changeset number, then it will only make sense for CI builds, since they typically build a single changeset.
For any other kind of build, I recommend using the build ID, which is unique, and covers the case of a build that builds multiple changesets.
We are using TFS Build 2010 for Builds. We have two branches of source code (Lets say branchA and branchB).
Now as a part of the build definition we set the projects to build:
Now to employ the same build definition from branchB will mean that I create another build definition file with same content, with only the items to build set to "$/branchB"
Is there anyway to make this configurable, without having to edit the build definition?
Also there are other input variables that we set for the build definition, and the values for these variables are included in the build definition XAML file. So to change the value of a variable will mean that we have to edit the build definition XAML file. This is not desirable.
I would like to be able to set the "Items to Build" and the variables of the build definition without having to modify the build definition XAML file.
Are there any solutions to these problems?
You can modify the Build Process Template so it only asks you for the Items to Build. The rest of the arguments are prefilled. To get an idea how this works, see http://www.ewaldhofman.nl/?tag=/build+2010+customization
You can add parameters to your build definition. I did this a while back because we had two web projects in a solution that had to be deployed to different servers (via Windows shares). I added parameters to the build def so that in the build properties I could customize them depending on if it was a dev deployment, staging, etc.
I added a blog post on how to do it. You can use the parameters this way so that they aren't kept in the XAML file.
Deploying Web Apps with a customized Build Process in TFS