Custom TFS build definition templates across projects - tfs

TFS provides a list of templates that I can use for new build definitions:
Once I've used "Save as template..." on a build definition, I can then use it as a template within that project:
But when I switch to a different project, that custom template is no longer available.
How can I create a build template that I can use in any project?

There is no way to directly copy or sync a vNext build definition template between team projects on the Web Portal. The build definition template is only for the present team project. So you need to create a build definition template for each team project.
And also there have been a feature request in user voice, you can vote up and monitor it
VSO build vnext: share build templates between projects
https://visualstudio.uservoice.com/forums/330519-team-services/suggestions/8468566-vso-build-vnext-share-build-templates-between-pro
However, for a workaround, you can use the REST API to perform this. Here is an example shown in the blog.
It shows how to get the JSON response of a build definition and again using the same reference to make a new one in the project you desire.
You can also take a look at this nice article: How to move build definitions in TFS to other projects using the REST API

As for now it is not supported but you can vote it up to make it happen faster:
https://visualstudio.uservoice.com/forums/330519-team-services/suggestions/8468566-vso-build-vnext-share-build-templates-between-pro

Related

How do I set some steps to automatically add to any TFS build definition?

Trying to get any TFS build definition to come pre-equipped with nuget restore so we can get the packages folder out of source control, but don't have a way to make sure these steps are at the beginning of every new build definition automatically. Any ideas?
You can't force it. You can encourage people to use templates (either the out-of-the-box templates or templates you create yourself), but you can't say "only allow users to create build definitions based on templates".

How do I create a new build definition in TFS 2017 across projects

We just upgraded from TFS 2013 to TFS 2017 and I was excited to go in and create a new build definition, but I can't seem to do it at the collection level. I can only create a new build definition once I've selected a project and then when defining the Get Sources page I can't seem to access other projects within the collection. The highest level it will allow me to get is the current project. In the Repository drop-down the only option is the current project. How can I create a new build definition across projects in TFS 2017?
The TFS build is project level for now, it's not able to create a build definition at collection level and across projects. For 2015 you could, instead of using the trigger path '$/{team project}', also insert just '$/', which would result in that the continuous integration build triggers on all check-ins in that team project collection. It's more like a backdoor.
However, In TFS 2017, it 's no longer possible to freely edit this field, and that you can only add a trigger for the team project that the build definition resides in.
There had been a uservoice and got started:
VSO build vnext: share build templates between projects
https://visualstudio.uservoice.com/forums/330519-visual-studio-team-services/suggestions/8468566-vso-build-vnext-share-build-templates-between-pro
As a workaround you could export your existing build definition in the project to other project. However, this just avoid you manually duplicating the definition in another team project. It's not able to get source from another project which different with the build definition belongs to.
There is an Export/Import Build Definition extension in Visual Studio Marketplace you can use now. Also available from within the TFS2017 update1 Build Definitions web UI:
.

Migrating a build definition from TFS to VSTS

I've been tasked with migrating a build from TFS to VSTS, I've used TFS from a developer point of view, however I've never created builds. Can anyone give me any advice where to start, good websites, tutorials, tools that might help, anything that might catch me out etc, basically my knowledge on this is very limited so anything would help. I've no doubt there must be somebody out there who can say we've done this, here is what we did...the new VSTS build will need to be a copy of the TFS build however some analysis needs to be done as the build process is old and certain parts may not be necessary. Thanks in advance!
Migrate New Vnext build definition from TFS to VSTS
If you want to template your builds or move them from TFS to VSTS, you could also use the REST API's to perform this. Details please refer this blog: HOW TO MOVE BUILD DEFINITIONS IN TFS TO OTHER PROJECTS USING THE REST API
Another example shown here. It shows how to get the JSON response of a build definition and again using the same reference to make a new one in the project you desire.
Migrate Old XAML to New Vnext build definition from TFS to VSTS
Unfortunately, there will not be any automated conversion processes. The new builds are based on a different architecture and run on a completely different system. And you can use both the new builds and agents alongside your XAML builds, controllers, and agents.
If you have heavily customized XAML builds and custom activities, you
can continue using those builds until you are ready to port your
business logic into scripts that can run in the new builds.
You should also take a look at these series of articles by jessehouwing devoted specifically to the case like yours.
About how to create a build, you could refer this tutorial from MSDN.

Customize TFS Build to include only specific files

I have a solution file with multiple projects that I am trying to configure for continuous integration on a development server using Team Foundation Server. I would like to customize this to only deploy the changes that were checked in.
Scenario example
Projects
My Project (MVC app)
Logic Layer
A user checks in a new Home.cshtml file and updates a code file in the Logic Layer. I would like to configure the automated build to just build the following package:
My Project
bin/MyLogic.dll
Views/Home.cshtml
What steps are done to achieve this scenario?
You want an incremental build, though I don't recall if it was supported back in TFS 2010.
Try configuring the build to not clean the workspace. Set the "Clean Workspace" property in the "Basic" section to "None".
Then, it will keep the binaries from the previous build, and, just like Visual Studio, will only build targets for which the inputs have changed.

Is there a workaround for not including custom activities in build controller?

I need some assistance with developing custom activities for TFS build. I have followed the steps in blog post Customize Team Build 2010 – Part 7: How is the custom assembly found?.
I have created a custom activity built into a DLL file and used in build template. I want to set it up in the TFS build now, but I have run into some issues. In the blog it suggests that the custom activities DLL file be referenced via the build controller. However, this is an issue for me. I work in a company where there are numerous projects and all use the same build controller. Therefore I don't have the permissions to make the change suggested in configuring the version control path to the custom activity.
Is there are another option open to me? Is there another way I can reference the custom activities? In the build template maybe?
You need to get that assembly onto the build server (build agent server assuming the activity is only used within the Run On Agent activity).
The most convenient option is to simply check it into the TFS folder that the build controller is pointing to for build assemblies, and the controller will automatically push it out to all build servers.
Alternatively, if you have direct access to the Build Agent Server(s) you can manually install the assembly onto the server into the GAC.

Resources