Preventing Checkin to trigger multiple Build with TFS 2010 - tfs

I have some Libraries added in my TFS 2010 project in a Lib folder.
Each time I check In a dll in the Lib folder, all the build that reference that Lib folder trig automatically (more than 20 Build).
I can use the ***NO_CI*** to prevent that. But I prefer to have something automatic.
Is it possible to have an event handler on TFS to prevent that.
Ex. If the check in is on that folder, do not scan all the CI Build Workspaces to trig the build.

The workspace mapping in the build definitions defines which files/folders are part of that build. You can use cloaked folders to explicitly exclude folders from the workspace.
However, the workspace mapping is used for 2 purposes: to determine which files get downloaded to the build server as part of the build, and to determine which files trigger CI/Rolling/Gated builds.
If you exclude folders from the workspace (e.g. using cloaked folders) it will stop the builds from being triggered but it will also stop those files from being downloaded as part of the build.
If you want to have a build download a certain folder as part of the build but not have builds triggered by check-ins to that folder I don't believe it is possible without customizing the build workflow.

When you include a folder in a workspace, you're saying that changes to that folder affect your project. This is the same for changes to shared source code as for shared binary. If it changes, then the affected applications should be built (and their automated tests should be run) so taht it can be determined whether the changed files have broken anything.

Make sure each library in the lib folder has it's own folder + version folders beneath
lib
EntityFramework
4.1
EntityFramework.dll
4.2
EntityFramework.dll
Then modify your builds to only reference specific folders for the library a project references.
It takes a lot of work to setup builds, but will ensure the build only triggers when a file needed for the build is changed.
Alternatively a copy of each library in the projects directory, which you could manage with a package manager like NuGet or OpenWrap

Related

VSTS Build not generating latest bin binaries

I am using TFS 2018 CI pipeline for MVC project, also I added the project's bin files into the TFS, there is no problem with the pipeline, its getting succeeded and artifact is generated successfully but the main problem is that if I made any changes in code related to project's DLL,
the CI pipeline's build solution not generating its own latest bin file
Until or unless I manually check Out the project.dll file and than check In the file than pipeline will pick the changes, what I am missing, same result by using 'MSBUILD' tasks, I also TICK clean the 'all directories' but same result
After spending whole day I came to the solution that, bin folder should not be added/included into the Source Control (TFS/Azure),
bin folder or project's binaries should not be added in to TFS
bin folder should be excluded in the project, after doing this operation, when I run the same build pipeline and inspect the artifact found that TFS builds added the bin folder and files accordingly, thats shocked me.
One thing should be remember in this case that what about external dlls reference, create a CommonDLLs folder at the same level of the src folder and put all external DLLs there. They are referenced through a relative path

TFS 2018 MSBUILD Download files task equivalent?

We are moving to TFS 2018 from 2012 and I'm working on migrating the builds. One of the builds has a few mtbwa:DownloadFiles activities in it but I don't see an equivalent way to do this in the new build system. We have a few utilities in a different branch that are used to build installers. So I need to download those utils before completing the build. How would I do this in the new build system?
If the files are in source control, then you can map the source directly in Get source step.
Then the files will be automatically downloaded to the $(build.sourcesDirectory) by deafult on the agent machine.
After that you can also add a Copy Files task to copy the files to any location as needed.
If the files are not in source control, you can also use the Copy Files task to copy them, but you need to make sure that the service account has the proper permission to access the source folder.
UPDATE:
If the team projects are in same collection, map sources in Get Sources step is also available. You need to manually specify the Server path (Click ... can only navigate to the root path of current team project).
e.g.:
In below screenshot I entered the server path $/2017ScrumProjectFromVS/WpfTest
This also works with the Copy Task, that means you can copy the files directly from another team project which in the same collection.

TFS - How to set build definition to build on workspace changes, but NOT download files to workspace?

I have our Solution on CI build. That works.
When dev's check in changes, the solution builds, but only for changes to that solution.
How do I get the build definition to build on changes to OTHER folder changes outside of the solution?
Yes, I can add a workspace in the workspace sources tab. But that means all that code is downloaded on every build.
Our solution has over a dozen dependencies. I would like to trigger a build if any of those dependencies change. We don't need the dependency source code to download into the build workspace at all. That's just pointless.
Yes, we have a folder in TFS for our Nuget Packages. We check them in automatically on build (Thank you TFS).
I could just add the NugetPackage workspace to the solution's workspace list, BUT that would result in every version of every dependency getting downloaded into the build workspace.
How can I trigger a build on a change that I do NOT list in the workspaces list of the build definition?
Btw, we are using TFS 2012
I was hoping the Cloaking feature would allow for this, but if it's cloaked, the automated build does not trigger. The automated build only fires if the workspace folder is set to active. Which also means download every NugetPackage in that same folder!
It's not able to trigger a CI build on a change which not list in the workspaces list of the build definition.
A few other things to know
Make sure the folders you include in your trigger are also included in your mappings on the Repository tab(the same to
workspace mappings).
Source Link
As a workaround you could set clean workspace to false, which will not get other unchanged files every time.
If your build process does not require a clean workspace or
repository, you can significantly reduce the time that is required to
run the build setting this parameter value to False.

TFS Builds - How to customise script to identify when not to build assemblies?

I have custom build definitions that builds all projects even if the only files that have been updated since the last build are css/javascript files.
You do not need to build assemblies when css/javascript files have been updated.
For the given scenario mentioned above, I want the build script to just copy those css/javascript files over to the web server.
How do I go about making my build script stop building assemblies when the only files that have been updated since the last build are css/javascript files? And then with those files, copy it over to the web server?
First, enable diagnostic logging into a file and rebuild. Examine that log and identify the target that is rebuilding and look for the output saying "rebuilding project due to cause".
How are you kicking off the build? Do you have any targets that touch files during the build process? Are these rebuilding because an aggressive target is minifying .js output, and the updated timestamp on the .js file is triggering a rebuild?
If that doesn't help, update your post to include the MsBuild script.

Setting up a build definition where the source relies on third party assemblies?

My structure for TFS is such:
{Main TFS Project}
3rd Party Assemblies
Development
Source
Integration
Source
I am using continuous integration for my development build, but currently I have to setup the working folder so that I am pointing to: {Main TFS Project} root folder. This is not ideal, because any check-in to the system kicks off my Development continuous build. I don't want to have the 3rd party assemblies in each branch, because they are shared throughout projects. What are other users doing?
Update
Before I wrote this message I had tried what kroonwijk had suggested, but my build still fails. this is what my work folders section looks like:
In the build definition, you have the ability to specify multiple folders to be downloaded to the build system when the build starts. From http://msdn.microsoft.com/en-us/library/hh190721.aspx:
When you create your build definition, on the Workspace tab, you
specify the folders that contain the files that you want to download
and how these folders should be mapped to local folders on the build
agent.
So just specify your 3rd Party Assemblies folder together with the Subproject folder you want to build in the Workspaces tab of your build definition, and only those folders will be checked and build.

Resources