TFS 2015 Release Management - Automatically create release branch in TFVC - tfs-2015

Is there a task in TFS 2015 Release Management that will automatically create a new Release Branch in TFVC when a release has been created successfully?
I'm trying to use a branch strategy similar to this, where release branches can be used for hotfixes: https://learn.microsoft.com/en-us/vsts/tfvc/branch-strategically#how-does-the-team-manage-releases-from-the-version-control-perspective

You can use a command prompt and use the below tf.exe command. Once all the steps complete the command prompt creates a new branch.
tf branch olditem newitem [/version:versionspec] [/noget] [/lock:(none|checkin|checkout)] [/noprompt] [/silent] [/checkin] [/comment:("comment"|#commentfile)] [/author:authorname] [/login:username, [password]]
For more information look at below
https://learn.microsoft.com/en-us/vsts/tfvc/branch-command

No. Your builds can label TFVC source upon success; in the event that you need to hotfix, you can just create a branch from that label. There's no need to create a servicing branch before you actually need it.

Related

How to recover deleted build definition

We are using the "new, scriptable build system" of TFS 2015 and all of a sudden one of our build definitions is gone. It seems that it deleted itself.
Is there a way to undelete/recover a build definition?
Where are the build definitions (those JSON files) acutally stored?
If you are on prem and you just chose delete from the GUI... run this in the TFS database for your specific id:
update Build.tbl_Definition
set Deleted = 0 --was 1
where DefinitionId = <your build ID goes here>
You will loose your build history without some extra work i did not take the time to dig into, but that might also be do-able.
NOTE: You will also loose credentials stored as build parameters you will need to recreate. Might even be best for you to recreate a new build using this as a template to avoid other unknowns.
TFS build definitions are not version controlled items. So, It's not possible to restore the deleted build definitions for now.
There has been a feature request in uservoice: provide a way to version-control build definitions According to the response from PM, this is still in process.
In the new build system coming with TFS 2015 you can see the full
history of the changes to your build definition. The feature that is
currently missing is the ability to undo or rollback to a previous
revision.
We expect to get the rollback deployed to our service in the next few
months.
Chris Patterson
Program Manager
Moreover, the build definitions are stored in the TFS database.

How to permanently save a build variable as a build step?

I have the following variables defined:
Now once a build is complete (the last step in the build process), I want to update the VersionRevision variable, basically increment it.
So I'm looking for an API I can call from C# and create a console application or a powershell script to edit the build definition (if I have to do this)?
You can use VSTS Rest API to update the variable value in Build Definition. Both Console Application and Powershell Script is OK for this.
If I understand correctly, you want to get these build variables and them assignment them as your version number.
After the build completes, update and increment the VersionRevision. It's not a good way and seems not available to achieve it.
In TFS build there is a $(Rev:.r) which means
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.
Source: Specify general build definition settings
To version your assemblies you could just add an powershell script in your build definition, detail ways to achieve please follow this link from MSDN: Version your assemblies
And usually we only define and assignment variables with the Major and Minor version. If you want to change the value of them. You may need manually edit the build definition.
More related link about how to manage version numbers as part of your vNext builds.
vNext Build Awesomeness – Managing Version Numbers
Generate custom build numbers in TFS Build vNext

Build only ChangeSet using MSBuild in Visual Studio Online

I have set up a Build Definition to build a solution on Visual Studio Online (VSO). It's working fine, but it builds all the code every time when I check in the code.
How can I build a particular changeset from the code?
How can I use/pass this number to the "MSBuild Arguments" to use it there for deployment?
You need to turn off the CI build feature(Uncheck "Continuous integration (CI)" option under "Triggers" tab in your build definition) if you don't want it to build all the code every time when you check in.
To build a particular changeset, you can enter the changeset number in "Source Version" textbox when you queue a new build. (In Git, it is "Commit" textbox)
To pass the version number to MSBuild Arguments, you can use the pre-defined variable "$(Build.SourceVersion)", it is filled with the source version number you specified when you queue the build.

tfs build email changes of last successful build

Is there some nice way, of sending all changes since last successful build and send me the changes?
I would prefer update my workflow process rather than *.proj file.
Any example would be appreciated.
so far I have found: Programatically find TFS changes since last good build
Its not fully functional but start is history command
http://daysincode.blogspot.co.uk/2013/05/tfs-history-command.html

TFS 2010 – Each new branch inherits custom groups permissions from main trunk

When branching from the main trunk in TFS2010 all the custom groups and permissions (as granted in the main trunk), are inherited by the newly created branch. This results in a fair amount of permissions that needs to be cleaned up in the new branch after creation.
(Each branch is a complete copy of the trunk)
I am making use of a script (bunch of tf commands) to set all new permissions on each new branch. As a last resort I am considering expanding this permissions script to manage the cleanup of the unwanted trunk permissions.
I am however hoping to treat the cause and not the symptom.
Is there any way to override this behavior?
I found the solution here: http://tfsbranchpermremoval.codeplex.com.
It involves writing a plugin for TFS and deploying it on the TFS app server. After deployment, no permissions from the Main trunk are inherited by any branches on branching actions.