TFS Check-In Enhancements - visual-studio-2010

I want to write a Visual Studio Plugin that will extend the functionality of Check-In command. What I want to happen is when a check in happens, I should be able to call an external program.

There are a few options to trigger a script or action when a user checks in:
1. Check-in policy
A checkin policy triggers in Visual Studio when checking in. The code that triggers is simple C#, so running an application is easy using the Process class.
These policies need to be deployed to the machines running Visual Studio. They will get an error message if the policy is not installed. You can create an MSI or vsix to deploy the policies. Or just copy them to the right folders manually.
2. Automated Build
A CI build or Gated build using a tool like Team Build or Team City would be ideal to run a program or piece of code. This would happen right after (CI) or just before (Gated) the final checkin, but they would run on the build server, not inside Visual Studio.
This can be either a MsBuild task or Team Build Activity.
3. Visual Studio Extension
You can also create a custom Visual Studio extension and then subscribe to the VersionControlServer.BeforeCheckinPendingChange event. This happens just before checkin. You can grab the VersionControlServer from the connected Team Project.

Related

How can I consistently automate, using TFS vNext build steps, building whatever solution files our development teams get working using Visual Studio?

Developers use the Visual Studio (VS) GUI to develop their solutions and get their projects all building using a solution file (.SLN). The build teams using vNext then have to automate those builds using MSBuild instead of devenv.exe (the Visual Studio executable file). This is a serious and chronic problem because not only is MSBuild incapable of building several project types, but the build order is defined in a completely different, and complex, way.
Some Microsoft advice (https://learn.microsoft.com/en-us/archive/blogs/msbuild/incorrect-solution-build-ordering-when-using-msbuild-exe) is to switch to explicit dependencies in each .*proj file and remove all dependency specifications in the .SLN file. This sounds like a person who has never worked in a relatively powerless build team trying to get development teams to:
do a lot of what they perceive as time-wasting extra work and to
change how they do things
What build teams need is a way to automate whatever VS allows dev teams to build. If VS is given a SLN to build, then a vNext build needs to be able to use that same SLN in the same way. Instead vNext currently only offers MSBuild as the build tool. MSBuild has many more options than devenv, so that would be great, IF it could be made to use the SLN to govern dependencies in the same way as VS, and would be upgraded to build all the same project types.
There have been prospective efforts, referenced by PatrickLu-MSFT at Build project using devenv.exe in TFS 15RC1 Build Server, to enhance a vNext build step to allow devenv to be used instead of MSBuild, but those efforts seem to have been dropped.
Maybe someone has developed a custom vNext build step to build using devenv?
Here is an existing extension you can reference, which provides a build task in your TFS/VSTS instance that will allow you to build your projects using DevEnv.com (Visual Studio):
https://marketplace.visualstudio.com/items?itemName=mmajcica.devenv-build
If you want to automatically use TFS/DevOps build whatever solution files our development teams get working using Visual Studio, you could set CI trigger in build pipeline, when the solution build successfully on local, you can check in/commit the changes, and trigger TFS/DevOps builds.

Visual Studio XAML Build Process Template - Get Comment

I'm currently creating a custom build process template as part of a Team Foundation Build definition, using Visual Studio 2013.
The builds are set to 'Continuous Integration - Build each check-in' as their trigger, and I'm looking to get some information about the check-in once the build starts running.
So far, I can get the following:
Build number using: Microsoft.TeamFoundation.Build.Activities.Extensions.WellKnownEnvironmentVariables.BuildNumber
Changeset ID using: Microsoft.TeamFoundation.Build.Activities.Extensions.WellKnownEnvironmentVariables.SourceGetVersion
These have both been retrieved using 'GetEnvironmentVariable' from the list of 'Team Foundation Build Activities'.
What I need now is the comment associated with that changeset. So the comment I set during the check-in that triggered the build.
Is this possible?

Associate changeset made within a TFS build to the build

I have a TFS build that runs on a schedule. Within the build process I have a step that checks out that project's properties file, increments the assembly's version number, then checks in the file bypassing any gated check-ins. This is creating a problem as the check-in of the properties file automatically sets the scheduled build to run the next day, causing an infinite loop.
My question is, is there a way to associate changesets made within the build process to the current running build?
I've tried refreshing the build detail and re-associating changesets after the msbuild compiles the project, but before the build finishes, without success.
Our projects are for Visual Studio 2010 and we are running against TFS 2013.
EDIT 12/21/15: For clarification:
I know about the NO_CI for bypassing CI Builds and including the /bypass in the command line. Overall my check-in that I am doing looks like the following:
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe" Checkin %My_FILE% /comment:"***NO_CI*** Version Updated to %NewVersion%" /noprompt /bypass
I"m having trouble with scheduled builds kicking off, because my check-in is telling it that there is a changeset to build.
You need to check in without triggering the build.
To tell the build system to ignore the check-in operation, a check-in comment value***NO_CI*** is specified to indicate "No Continuous Integration" meaning "please don't start a CI build because of this check in". Place the following into the comment field:***NO_CI***and when you check-in TFS will not kick off a build. More details for your reference: http://bartwullems.blogspot.hk/2012/08/tfs-do-check-in-without-triggering.html
update
You could customize your build template and add in the custom TFSVersion activity from the TFS Community Build Extensions that will handle this. Detailed steps for your reference:http://tfsbuildextensions.codeplex.com/wikipage?title=How%20to%20integrate%20the%20TfsVersion%20build%20activity&referringTitle=Documentation

How do you trigger a build when you check in code using VSO and visual studio 2013?

I am developing using Visual Studio 2013 with Visual Studio Online for source control. I want to prevent check-in if the build that is triggered is returned false. Using the steps below, don't see how the builds are happening and not sure how to enforce good check-ins?
I completed the following steps:
https://www.visualstudio.com/en-us/get-started/build/build-your-app-vs
Since you are using TFVC the. You would need to use Gated Build as the trigger. Unfortunately Gated Build has not yet been implemented on the new Build system and is only available on the legacy Xaml builds.
If you were using Git you could take advantage of the Branch Policies to require that a build succeed before a checkin was allowed through Pull Requests.
You can either change your source control to Git and use Pull Requests, or you could change your build system to the Xaml builds and use Gated Build.

Visual Studio Scheduled Build Trigger

I am using the new Visual Studio build definitions on Visual Studio Online under Build. I would like to run a scheduled build every day for the branch TestingBuildDefinitions1 only if there have been changes in the branch since the previous build.
I cannot find the option to run scheduled builds only if there have been changes. The MSDN documentation says there should be a "Build even if nothing has changed since the previous build" checkbox. However, the new screen does not have this checkbox.
The documentation is referring to the old Xaml based builds, while the UI you are using is for the new VSO Build vNext, which does not have the functionality you are looking for.
If you want to create a new Xaml based build, you will need to do it from the Visual Studio client (it cannot be done from the portal).
Start by clicking on Builds in Team Explorer

Resources