Integrate a TFS Build with Release Management - visual-studio

How do I create a TFS Build which automatically runs a Release (deployment) from Microsoft's Release Management for Visual Studio 2013?

In order to start a release off from your TFS Build, you need to change the Build Definition. Luckily when you install Release Management it creates a Build Template for you to use with an example. In may instances this will be enough to get you going.
Release Management Build Process Template
Release Management Build Process Templates are not installed in TFS by default, so it won’t appear as an available build process template until you add it.
Find the Template in your server install in : C:\Program Files (x86)\ Microsoft Visual Studio 12.0\ReleaseManagement\bin\
TFS 2010 : ReleaseDefaultTemplate.xaml
TFS 2012 : ReleaseDefaultTemplate.11.1.xaml
TFS 2013 : ReleaseTfvcTemplate.12.xaml (or ReleaseGitTemplate.12.xaml if using GIT)
To add the release management build process template, you will need to check it in to your TFS source control in the BuildProcessTemplate folder in your project. Then add the build process file when editing (or adding) a Build Definition. Once the release management template has been added to the list of build templates, you can start using it.
Please ensure you use the above templates from the Release Management Server and not the client directory as I did initially. You will get rather odd errors during your build if so, such as:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets (3883): Web deployment task failed. (Unknown ProviderOption:DefiningProjectFullPath. Known ProviderOptions are:skipInvalid.)
Package Pickup \ Path to package.
When you set up your components, Release Management needs to know where to pick up your installation files to do something with them. When you created your Release Template it should be connected to a specific build by selecting the build definition that will initiate it (also tick "can trigger a release from a build?"). When you add the components to install as part of your release you specify their Source. "Builds with application" should be selected. The bit that got me was the big empty box next to the Build Drop location which is a mandatory field. My initial reaction was to fill it with the name of the msi file I was trying to deploy. That makes sense right? wrong. If I queued a build from Visual Studio I kept getting the following message.
Package location '\\blah\blah\Build Name\Build Name_20140707.3\A.Product.To.Install.msi' does not exists or Deployer user does not have access.
The file did exist in the location and the user the deployment agent was using did have access to the drop directory. I had also confirmed it was able to access it using ProcMon. After sleeping on it I decided to hover my mouse over the input box and a nice tooltip pops up saying:
The package path relative to the build drop location is required for
component bound to a Release Template. If the package is directly at
the root of the build drop location, you need to enter the '\'
character.
So, after my eureka moment, I deleted the msi file name and replaced it with a "\" and queued the next build. It worked. In retrospect I think they should remove the mandatory requirement for something to be entered to replace the need to enter a "\". It's a little hidden and not intuitive.
See MSDN Article here for more info
For Modified Build Process Templates

Related

Unable to access symbols published in VSTS Symbol server from visual studio

I'm able to successfully publish symbols to the VSTS symbol server as part of the build execution.
Followed this link to setup visual studio and everything good until this point. My symbol settings shown below:
When trying to debug, visual studio hits VSTS symbol server but return error message “Cannot find or open PDB file”
Below is the symbol load information provided by visual studio after trying to fetch from VSTS symbol server
As of November 15 2017 Visual Studio Online (also now known as Azure DevOps) the Index Sources and Publish Symbols build step handles the new portable PDB's create by dotnet build
You should tick Publish symbols and select your Subscription. The free tier has 5 users. You need to assign each user access to symbol server.
Ticking the Index Sources check box makes no sense though as the source files are on the build server, usually in an obscure location such as C:\agent\_work\34\s\... which will not match your local (or network path) to the source files.
To help Visual Studio find the source files you can do this... (you can avoid this by using SourceLink as described below)
Select the solution in Solution Explorer and then choose Properties from the shortcut menu.
Under the Common Properties node, choose Debug Source Files.
Click the folder Tools/ Options/ Debugging/Symbols folder icon icon. Editable text appears in the Directories containing source code list.
Add the path that you want to search.
When you start debugging all the symbols will download and you can step into the source code now.
This does NOT require disabling just my code and you do not need to enable source server either.
Unless you are using, or would like to use source server. It is pretty easy to do now by adding a few packages...
With AzureDev ops you can modify your build pipeline to make use of soruce files stored in GIT byt following this guide.
The prerequisite is .NET Core SDK 2.1.300 or desktop msbuild version
15.7.
On your package project project you need to add NuGet package "SourceLink.Create.CommandLine" which will enable your build server (and your local build machine) to rewrite parts of the Portable PDB's without changing anything in the build pipeline.
You also need to add a package to the correct source control. As described in this article. - I am using VSTS so I just install "Microsoft.SourceLink.Vsts.Git" package (must enable Include Prelease as of writing now)
To verify this works all you need to do is build the project and look inside \obj\{config}\{tfm}\ for a file called *.sourcelink.json and has the correct URL's inside it.
Then the usual pack and publish you would do.
In Visual Studio you just need to enable
Enable Source server support
Enable Source Link support
You need to run the application built in the same build as the build to publish symbols to VSTS Symbol server, the identity will be different in the different builds.
You can find that there is the GUID (0CD368C47775439…) in the Symbol load information, also you can check the Publish symbols task’s build log, there is the GUID too. Within a build the GUIDs will be the same and the symbols will be loaded correctly during debug.
Did you enable Source Server Support in the VS.NET debug options ?
You might also uncheck 'Enable Just My Code' in the VS.NET debug options.
There's a blogpost that I've recently written where I explain setting up and using a symbol server; might find some tips that might help you with your problem.

VSTS: Release and deploy a console application

We have a C# .NET project using Visual Studio 2013 and we're setting it up to release and deploy with Visual Studio Team Services (VSTS). The websites were pretty simple and easy to set up and they work fine. A few projects are libraries or Console applications and we're trying to determine the best method for creating an automated release for these.
The publish profile asks for a location to publish to - we've experimented with the build drop on our VSTS build server (where all of the other files are) and then asks for a website, a UNC path or a CDROM. We chose "UNC Path" and put the same build drop location in, but in UNC format.
It hasn't really worked yet, so I thought I would see if any best practices for creating VSTS releases and deploys for Console or Code Libraries exist.
Thank you!
Have you considered installing the agent on the target environments and using a release definition that simply copies the right files at the right place?
Regards
Note: copy path shouldn't be hardcoded and rely on variables.
To specify the agent queue by going to the tasks tab when editing the release definition. Click on the "run on agent" header, that will open the details, select your queue here.
Agent queues can contain multiple agents, so your job when you add agents is to organize them by queues that make sense in your context.

TFS to Release Management - Release from Build

I am so close yet so far from getting my Visual Studio (MVC) application released through TFS & Release Management. I am using Version 2013 and have my build definition setup as follows:
As you can see it is using the TfvcTemplate.12.xaml as its template, and as such I cannot see the options for Release as I have been finding in all other examples online - eg:
I have gone into Release Management and setup my Release Template to reference this build definition and selected 'Can Trigger a Release from a Build'... but I have nothing happen in RM when I Build in Visual Studio.
What I have also found is that because the application I am building is MVC with Windows Authentication - every time I run a manual release, the Web Site gets rebuilt (as per my release template), but the website is always rebuilt with Windows Authentication Disabled... Which is a pain as I keep having to go into IIS after every release to enable Windows Authentication.
So, my questions are...
1) What am I doing wrong with my version of the Build Definition setup that it will not prompt a release?
2) Do I have to Remove and Create my website on the Release Template... and if so...
3) How do I get around the fact I always have to revisit IIS to enable Windows Authentication after each release?
Thanks!
You need to switch your build template to ReleaseTfvcTemplate.12.xaml.
You can find that file in the folder:
Program Files (x86)\ Microsoft Visual Studio 12.0\ReleaseManagement\bin
You need to check that into your TFS repo, then switch your build definition over to use it.https://msdn.microsoft.com/library/ms181355(v=vs.120).aspx#add_template

Automatically place drop in source control folder - VSO Build

I am building my solution in Visual Studio Online Build, the default 'steps' are build/test/index+publish/publish build artifacts. I want the build to be placed in a folder in my source control (rootfolder/builds). However, I don't see an option to enter an output-path anywhere.
EDIT: I see that next to 'timeline' on the build screen there is the option to view the 'Artifacts', but, I want to see/copy the drop to my TFS online project folder like '$myproject/mybranch/builds/'
The option to store the build drop on the TFS server is no longer supported. It was introduced as a temporary measure in 2012 and replaced with server drops in 2013.
Server drops are stored in an unversioned store in TFS/VSO and does not incur the overhead of versioning.
In TFS 2015 this transitioned to the new Artifacts repository. All build output is stored on the server and is accessible in the web, and through an API.
The way things stand right now, this is not possible. You have two options to drop your build outputs
Team Foundation Server
UNC file share if you use a on-prem agent.
See the Artifact Type argument on Publish build artifacts.
I it is possible with a custom powershell task. I have recently created a powershell build task that could "check-in" your drop artifacts into a folder like $myproject/mybranch/builds.
Have a look : https://github.com/skuvnar/visual-studio-team-services-scripts.
Although its possible, I would suggest against it - could lead to all sorts of trouble with the builds.

Build->Deploy doesn't work for database projects

I have a database project in Visual Studio 2012. When selecting "Deploy MyDBProj" on the Build menu nothing happens.
When I hit F5 to debug however, the database project is deployed, using the settings in the debug section of the database project properties. This is enabled in by checking the "deploy" checkbox in the solution's configuration manager.
I would like to be able to do a deploy, without starting a debug session. How do I do that?
Note: This is not publishing, which is something else. I want to know how to manually initiate the deploy that is part of the build process. Since the deploy is already done automatically it should be possible to initiate it manually too.
I got an answer from Microsoft at MS Connect:
There was a bug in the version of SSDT that shipped in Visual Studio
2012 in wuich the Deploy menu command appears but is a no-op. This has
since been fixed and is available in the latest version of SSDT:
http://msdn.microsoft.com/en-us/data/hh297027
The only way I can think of doing it (though I haven't tested it) would be to use the command line to do it as outlined at http://msdn.microsoft.com/en-us/library/dd193258(v=vs.100).aspx.
Though once you have your manifest, you can run:
VSDBCMD /a:Deploy /dd:+ /manifest:manifestFileName.dbmanifest
from a command line to deploy your database.
The manifest will contain your target database name, connection string, and so on but you can also specify those as part of the command line instead.

Resources