Showing posts with label tfs. Show all posts
Showing posts with label tfs. Show all posts
Saturday, November 19, 2016
Switching environments, data sources, and other dynamically changeable settings in TFS Lab (on-premise) for 2013
Thanks to a post on this blog, we can access the settings inject into Lab-managed builds in TFS 2012 and 2013. Even though this is 2016 and many people are moving to the cloud with VSTS, there are still a good number of companies out there with considerable infrastructure "on-premise", and TFS can help with executing automated tests in those environments. I'm going to be building a library for helping others out with retrieving settings dynamically from TFS and I'll update my blog when it's available.
Monday, May 02, 2016
Migrating code in TFS from one Team Project to another Team Project within the same Team Project Collection
My company has frequently had the issue of moving code around within the same Team Project Collection as shifting desires and motivations for the organization of our code have swayed our company. Previously, we've used tools such as the TFS Integration Platform available on code plex. That project has its share of issues, namely that:
a) It was half baked to begin with
b) It's no longer maintained and doesn't work for versions later than TFS 2012.
Fortunately for me, thanks to a fortuitous Stack Overflow post, I've found the following script to recursively move the content of one folder to another folder, and it even works across Team Projects within the same collection (but not across Team Project Collections):
Param(
[Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][string] $SourceFolder,
[Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][string] $TargetFolder
)
Get-TfsChildItem $SourceFolder |
select -Skip 1 | # skip the root dir
foreach {
& "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\TF.exe" rename $_.serveritem $_.serveritem.replace($SourceFolder, $TargetFolder)
}
In order to run the script above, you'll need both Visual Studio and TFS Power Tools installed. When you install the Power Tools, you'll need to ensure that the PowerShell module is selected in the installation options. Also, because the path to the Power Tools PowerShell module isn't put in the PSModulesPath by default, you'll have to manually import the module into your PowerShell settings like so (before you run the script):
Import-Module "C:\Program Files (x86)\Microsoft Team Foundation Server 2013 Power Tools\Microsoft.TeamFoundation.PowerTools.PowerShell.dll"
a) It was half baked to begin with
b) It's no longer maintained and doesn't work for versions later than TFS 2012.
Fortunately for me, thanks to a fortuitous Stack Overflow post, I've found the following script to recursively move the content of one folder to another folder, and it even works across Team Projects within the same collection (but not across Team Project Collections):
Param(
[Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][string] $SourceFolder,
[Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][string] $TargetFolder
)
Get-TfsChildItem $SourceFolder |
select -Skip 1 | # skip the root dir
foreach {
& "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\TF.exe" rename $_.serveritem $_.serveritem.replace($SourceFolder, $TargetFolder)
}
In order to run the script above, you'll need both Visual Studio and TFS Power Tools installed. When you install the Power Tools, you'll need to ensure that the PowerShell module is selected in the installation options. Also, because the path to the Power Tools PowerShell module isn't put in the PSModulesPath by default, you'll have to manually import the module into your PowerShell settings like so (before you run the script):
Import-Module "C:\Program Files (x86)\Microsoft Team Foundation Server 2013 Power Tools\Microsoft.TeamFoundation.PowerTools.PowerShell.dll"
Sunday, February 28, 2016
Continuous Delivery of Azure Web Services
See this:
https://azure.microsoft.com/en-us/documentation/articles/cloud-services-dotnet-continuous-delivery/
https://azure.microsoft.com/en-us/documentation/articles/cloud-services-dotnet-continuous-delivery/
Monday, February 08, 2016
How to move a shelveset from one branch to another in TFS
You're going to have to start by installing the TFS PowerTools for TFS 2013 (or whatever version is appropriate for you). Once you have the powertools installed and the tools added to your PATH (if they're not already added by the installer), run a command similar to the following in the command line:
tfpt unshelve /migrate /source:"$/ProjectName/Branch" /target:"$/ProjectName/Targetbranch" "My Shelveset Name"
This will unshelve your shelveset into your new branch for you.
WARNING: Before you do this, make sure you're unshelving into a clean branch with no Pending Changes, otherwise you could inadvertently overwrite or otherwise lose important changes.
tfpt unshelve /migrate /source:"$/ProjectName/Branch" /target:"$/ProjectName/Targetbranch" "My Shelveset Name"
This will unshelve your shelveset into your new branch for you.
WARNING: Before you do this, make sure you're unshelving into a clean branch with no Pending Changes, otherwise you could inadvertently overwrite or otherwise lose important changes.
Sunday, October 18, 2015
Accessing TFS via PowerShell
I'm ashamed to admit that only today did I find out that there are PowerShell cmdlets for TFS.
You can load them into a PowerShell session by executing this:
add-pssnapin Microsoft.TeamFoundation.PowerShell
Once that's done, you can get started with the following commands:
Get-Help Get-TfsServer
See this post on Hey Scripting Guy.
You can load them into a PowerShell session by executing this:
add-pssnapin Microsoft.TeamFoundation.PowerShell
Once that's done, you can get started with the following commands:
Get-Help Get-TfsServer
See this post on Hey Scripting Guy.
Thursday, July 30, 2015
Bitten by IIS, or lack thereof
Here at the office, we build a number of web applications. I recently started refactoring one such application to change and improve how we deploy it. As soon as I made the change to the .csproj to remove some old configurations and add new ones, I mysteriously started getting this error on our build machine (and only our build machine):
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets (2664): Filename: redirection.configError: Cannot read configuration file
After examining the changes I made, I figured "there's nothing that should be causing this. WTF?" Then after a while, I went on to our build machine and found that we didn't actually have IIS installed on the build machines (which is a good idea from a security standpoint, because there's really no reason for a build machine to have IIS installed). So why did this start suddenly ?
I went and examined the exact line that was causing the problem in the targets file, and the only thing that appeared to be including this conditional statement was the flag 'IncludeIisSettings'. Sure enough, the old configuration which we never used before and were using now had this set.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets (2664): Filename: redirection.configError: Cannot read configuration file
After examining the changes I made, I figured "there's nothing that should be causing this. WTF?" Then after a while, I went on to our build machine and found that we didn't actually have IIS installed on the build machines (which is a good idea from a security standpoint, because there's really no reason for a build machine to have IIS installed). So why did this start suddenly ?
I went and examined the exact line that was causing the problem in the targets file, and the only thing that appeared to be including this conditional statement was the flag 'IncludeIisSettings'. Sure enough, the old configuration which we never used before and were using now had this set.
Tuesday, October 28, 2014
Correcting the default check-in action for associated work items in Team Foundation Server
I've found that it's a giant pain in the ass in TFS when associating work items to checkins because the default assocation action is 'Resolve' rather than 'Associate'. When I'm working on features, I like to do bits of functionality in units and check them in to source control in small batches to make my changes more manageable. Unfortunately, many times I've forgotten to change the association action when associating work items with change sets and it's resolved my issue instead of just associating the work item with the change set. This becomes problematic because it skews my records and metrics for how much time is spent working on a task. Fortunately one can change this in the registry:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\[Version Number]\TeamFoundation\SourceControl\Behavior
Quick fix.
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\[Version Number]\TeamFoundation\SourceControl\Behavior
Quick fix.
Friday, October 24, 2014
Regarding pre-test invocation scripts when deploying to a Test Agent with TFS
So, I learned something interesting about TFS Test Agents today and they way they handle pre-test invocation scripts when running tests on a Test Agent. In Microsoft Test Manager, do the following:
- Connect to a Team Project
- Change into 'Lab Center' mode
- Click on 'Test Settings' in the top bar-ish area. This will open up the Test Settings Manager.
- Edit or create a new 'Test Settings' item and open it up.
- In the 'test settings' editor, under the 'Steps' column on the left-hand side, go to 'Advanced' -> 'Scripts'. You're now presented with the scripts page where you can specify scripts to be invoked before and after the execution of your test run.
Now, **here's the important thing** :
The script file(s) you specify in these boxes do not get copied to the Test Agent per se. Instead, their contents get read and merged with an automatically generated script that's created by the Test Agent. The script that actually gets run on the Test Agent will look similar to the following:
REM **************************************************************************** REM * Generated by Microsoft Visual Studio REM * Copyright (c) Microsoft Corporation. All rights reserved. REM * REM **************************************************************************** set ResultsDirectory=C:\Users\Autotest\AppData\Local\VSEQT\QTAgent\23620\00C4EF~1\Results set DeploymentDirectory=C:\Users\Autotest\AppData\Local\VSEQT\QTAgent\23620\00C4EF~1\DEPLOY~1 set TestRunDirectory=C:\Users\Autotest\AppData\Local\VSEQT\QTAgent\23620\00C4EF~1 set TestRunResultsDirectory=C:\Users\Autotest\AppData\Local\VSEQT\QTAgent\23620\00C4EF~1\Results\00C4EF~1 set TotalAgents=1 set AgentWeighting=100 set AgentLoadDistributor=Microsoft.VisualStudio.TestTools.Execution.AgentLoadDistributor set AgentId=1 set TestDir=C:\Users\Autotest\AppData\Local\VSEQT\QTAgent\23620\00C4EF~1 set BuildDirectory=\\SOMESERVER\SomeShare\TFSDrops\HRST\CWSTAM~1.SPR\CWSTAM~3.1 set DataCollectionEnvironmentContext=Microsoft.VisualStudio.TestTools.Execution.DataCollectionEnvironmentContext set TestLogsDir=C:\Users\Autotest\AppData\Local\VSEQT\QTAgent\23620\00C4EF~1\Results\00C4EF~1 set ControllerName=TSTTFSTHR01:6901 set TestDeploymentDir=C:\Users\Autotest\AppData\Local\VSEQT\QTAgent\23620\00C4EF~1\DEPLOY~1 set AgentName=00C4EFD8-A65F-4B5E-AD5F-04F93895B543 REM **************************************************************************** REM * User Commands REM * REM **************************************************************************** echo "My actual user commands from my script file here"
This is important to keep in mind when you're writing the commands in the script to be executed, because no files get copied with the script file you reference in the Test Settings, and there's no mention of where that script file originally came from, so the script is effectively executed without any context except for that which is given to it by the TFS Test Agent in the prefixed lines.
Tuesday, July 15, 2014
Making TFS builds consistent with desktop builds when invoking MSBuild directly on a .*proj file
As it turns out, MSBuild has more than a few quirks when being invoked through TFS compared to being invoked through a command line or from Visual Studio. Some of them are pretty well documented. Others are not, like the fact that in a .*proj file, the OutDir variable is inherited to sub-MSBuild tasks. There's also quirks because OutputPath is used to determine OutDir, but not in all cases. If you're going to specify OutputPath in the properties when invoking the MSBuild task, you should also explicitly override the OutDir variable as well to ensure consistency, unless you **TRULY** understand the differences between the two and how MSBuild determines OutDir, and you **REALLY** want it to be that way.
Thursday, June 26, 2014
Getting code signing to work with ClickOnce on a TFS Build Agent
Code signing is a giant pain in the butt. You have to :
- Obtain the certificate for signing the code by:
- buying the certificate from an issuer.
- generating your own self-signed certificate
- Configure ClickOnce within your project file with the following property elements:
- <signmanifests>true</signmanifes>
- <manifestcertificatethumbprint>A387B95104A9AC19230A123773C7347401CBDC69</manifestcertificatethprint>
- Log into your machine **as the user running the build controller / agents ** and import the key to their user Personal certificate store!
- Run 'certmgr.msc' from the Run command in the start menu (WinKey + R is the hotkey)
- In the Certificate Manager that comes up, go to Personal in the tree, right-click, and select All Tasks -> Import ...
- In the Certificate Import Wizard window that comes up, select Next to move to the 'File To Import' screen.
- Select your certificate file, which has the same thumbprint as specified in your project file, then click Next to move to the 'Certificate Store' screen.
- In the 'Certificate Store' screen, select the 'Place all certificates in the following store' option, then click Browse to select the store. Choose 'Personal' in the selection window. Click Next to move to the "Completing the Certificate Import Wizard" window.
- On the "Completing the Certificate Import Wizard" window that comes up, click Finish to import the certificate.
You should now be able to build and sign your code on a TFS Build controller / agent.
Labels:
agent,
build,
certificate,
clickonce,
code,
controller,
sign,
tfs,
thumbprint
Subscribe to:
Posts (Atom)