How to automate Build/Release definitions in TFS 2018? - tfs

I wish to automate management of my Build/Release definitions, for easy backup/restore operations.
How can I do this in TFS 2018? I'm open to using either the REST API or the SDK, although I prefer the SDK whenever possible.
--EDIT--
This is for TFS, not VSTS

In TFS 2018 and later versions, it supports export/import build/release definitions directly. Build/Release definitions are implemented internally as .json files, so you can see details on changes in the file’s history:
Check the following release note:
https://learn.microsoft.com/en-us/visualstudio/releasenotes/tfs2018-relnotes#buildimport
Or you can use TFS REST API to get build and release definitions:
TFS build definition
TFS release definition
Adding a screenshot of how to check build definition history:

Related

Versioning builds/releases in TFS 2017

I have an ASP.NET Core 2.0 project in TFS 2017, and I'd like to specify a version number when our project builds (whenever changes are pushed to master). Is there a simple way to accomplish this? I found several tools that seem to be for this, but I can't figure out how to use them. (GitVersion | Semantic Versioning Build and Release Tasks)
You need to create a CI build or CD release against the master, then it will trigger the build/release whenever changes are pushed to master.
For versioning the .Net Core project, you can reference this article : Versioning .NET Core in Visual Studio Team Services
For the GitVersion Usage, please refer to this link: http://gitversion.readthedocs.io/en/latest/usage/usage/
Besides, you can also use the .NET Core CLI tool to update the version information in .NET Core *.csproj files.

Using TFS 2015 Build to build projects in TFS 2013

We currently use TFS 2013.
I'd like to do a POC where I can create some build definitions in TFS 2015 where it would get the source from our existing TFS 2013 server. Once the boss sees how much easier it is to manage our builds from TFS 2015, I'm sure he'll give us the go-ahead with upgrading the existing TFS 2013 to TFS 2015.
Is this even possible?
You could write a PowerShell script or some batch files to leverage tf.exe in order to map a workspace / clone a repo (depending on whether you're using TFVC or Git) as part of a build. Or just put the tip of your source code into the "demo" environment and build from there. The latter option is going to be much faster.

Continuous Delivery with TFS 2010 and Jenkins?

Our development team uses Visual studio 2013 Pro along with TFS 2010. We need the following abilities for our continous integration / delivery initiative:
1. Automatically build our web project on every checkin.
2. Automatically deploy green builds to development and/or test environments.
3. Provide build/deployment notifications via email.
Extra Credit: Run unit tests with each build.
We don't have a budget, the reason Jenkins is appealing. The setup is new to me and not sure how the pieces fit and what other tools are needed to preform the tasks above?
If you have MSDN subscriptions, you can use TFS for free. TFS 2015 can provide all these features. TFS 2010 can provide most of this as well.
Use a gated checkin or CI build definition in TFS (2010 and 2015) to automatically build on checkin and run tests. The build definition has the option to run tests as part of the build.
Use MSDeploy to package up your components into an automated package. Most people don't know you can use it for more than web applications. (For example, databases)
TFS also provides email alerts on many events.
Regarding automating the deployments, we used separate TFS (in 2010) build definitions to trigger deployments to each environment. Now we use TFS 2015 which supports release definitions that adds many more options.

How can I put xaml build definitions in source control in Visual Studio 2015?

I use Visual Studio 2015 and TFS 2012. In Team Explorer, it is possible to manage Builds and Build Definitions. Since VS2015, the section Build Definitions is named "XAML Build Definitions". I would like to put xaml build definitions in source control. Problem is I cannot find the build definition files on disk. Anyone knows where they are ?
Thanks
You can download build process template and add it into source control, but you can't version-control build definitions.
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. Check https://visualstudio.uservoice.com/forums/330519-team-services/suggestions/2037625-provide-a-way-to-version-control-build-definitions
Just in case anyone needs to access the XAML Build Definitions parameters. They are saved in the TFS database, table: [dbo].[tbl_BuildDefinition].

Integrating FxCop and StyleCop into TFS 2010/VS continuous integration process

I'm setting up a continuous build process on Jenkins, TeamCity and TFS 2010 to compare them. In Jenkins and TeamCity I'm building the project on every check-in, and I've set up FxCop and StyleCop analysis and reporting. Now I want to do this in TFS 2010.
If I want to make sure FxCop (or Visual Studio Code Analysis) and StyleCop is being run on every check-in, how do I do that with TFS 2010/VS? I'm also wondering if there are several ways of doing it (Continuous integration vs gated check-in)?
There's a few different ways to run these as part of the build. For FxCop you can set the PerformCodeAnalysis property on the TFS Build Definition. Personally I prefer to pass in the following values using the MSBuildArguments property on the Build Definition:
/p:RunCodeAnalysis=True /p:CodeAnalysisRuleSet="..\Foo.ruleset
For StyleCop I use the custom activity from the Community TFS Build Extensions project. You can find the binaries and instructions here: StyleCop Custom Activity

Resources