Associate changeset made within a TFS build to the build - visual-studio-2010

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

Related

Visual Studio 2015 - Minimum Rebuild when Start Debug

My project has 15 projects and 1 solution file
If my source code has not been modified, Visual Studio prompts me if I want to build the 15 project files?
There is a box to say not to display it again, I'm not sure why Visual Studio thinks the code is out of date?
Thanks for the feedback
If my source code has not been modified, Visual Studio prompts me if I
want to build the 15 project files?
No. If your code has not been changed, it will always show up-to-date, not build. VS has the feature of incremental build.
Note: you should click Build button rather than Rebuild. Rebuild will execute clean and then build, so it will always execute the whole build process.
Once you do not modify the resource files, MSBuild will detect that the project has not changed and does not need to be built again, turns out to up-to-date.
Therefore, under normal circumstances, MSBuild will not build again without changing the project.
There is a box to say not to display it again, I'm not sure why Visual
Studio thinks the code is out of date?
In fact, it should not happen.
If you have not made any changes to the project but the build still displays out-of-date, you have to check the diagnostic build log and find it out.
Enter Tools-->Options-->Projects and Solutions-->Build and Run--> set MSBuild project build output verbosity to Diagnostic . And then build your project to find the cause out.
Maybe you have set Copy To Output Directories of some files to Copy always or you have lost the files for inputs and ouputs, .... so on.

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.

TFS Check-In Enhancements

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.

trigger build tasks in visual studio and tfs build

I have a c# solution with multiple projects. I have a .sln file I build the solution with in VS2012.
I am looking to set up TFS Build and want to include some custom msbuild actions, such as running stylecop and fxcop rules. I want these tasks to fire when building the solution locally and within tfs build.
I have looked at creating a .proj file for the solution. However, I am not sure how this can be setup locally and to run the tasks locally.
What is the correct setup for tasks to be run within tfs build and visual studio?
My best guess is to set the flag "Enable Code Analysis on Build" in the project settings "Code Analysis". More on that here.
I suppose that running StyleCop is better fitted in the IDE (check R#) or the VCS (check SVNStyleCop) on commit. I am not sure if the same exists for GIT or other repositories.

Gated Checkin build ignores [SuppressMessage] in source

We want to refuse checkins which break our custom defined static code rules. Therefore we have defined a Gated Checkin build, with "Perform Code Analysis" set to 'AsConfigured'.
When I build the solution locally, using the same configuration and target as defined for the Gated Check in build, there are no errors. But the Gated Checkin build seems to ignore any [SuppressMessage] attributes that we have defined in source, thus reporting errors.
The Gated checkin build does not ignore [SuppressMessage] attributes that are defined in a GlobalSuppressions file.
Any one else have this problem?
When you said you build locally fine, did you build from Visual Studio, or did you build with MSBuild?
TFS Build uses MSBuild to build the projects, and you should be able to see what MSBuild command is run during the build by looking the log from the build report (if you set the verbosity level at least to Normal).
To investigate this issue, I would recommend you use this MSBuild command to build your solution locally (you would need to change the path to the solution on your machine, rather than the path used on the build machine), and it will likely give you the same errors, which indicates a discrepancy between building with MSBuild and building with Visual Studio. Then we can look at the MSBuild command and see why it does not behave the same way.
Hope this helps.

Resources