A test of the social publish on the blog server
Our testing environments are based on TFS Lab Management, historically we have managed deployment into them manually (or at least via a PowerShell script run manually) or using TFS Build. I thought it time I at least tried to move over to Release Management.
The process to install the components of Release Management is fairly straight forward, there are wizards that ask little other than which account to run as
- Install the deployment server, pointing at a SQL instance
- Install the management client, pointing at the deployment server
- Install the deployment agent on each box you wish to deploy to, again pointing it as the deployment server
I hit a problem with the third step. Our lab environments are usually network isolated, hence each can potentially be running their own copies of the same domain. This means the connection from the deployment agent to the deployment server is cross domain. We don’t want to setup cross domain trusts as
- we don’t want cross domain trusts, they are a pain to manage
- as we have multiple copies of environments there are more than one copy of some domains – all very confusing for cross domain trusts
So this means you have to use shadow accounts, as detailed in MSDN for Release Management, the key with this process is to make sure you manually add the accounts in Release Management (step 2) – I missed this at first as it differs from what you usually need to do.
To resolve this issue, add the Service User accounts in Release Management. To do this, follow these steps:
Create a Service User account for each deployment agent in Release Management. For example, create the following:
- Create an account in Release Management, and then assign to that account the Service User and Release Manager user rights. For example, create Release_Management_server\LocalAccount1.
- Run the deployment agent configuration on each deployment computer.
However I still had a problem, I entered the correct details in the deployment configuration client, but got the error
The logs showed
Received Exception : Microsoft.TeamFoundation.Release.CommonConfiguration.ConfigurationException: Failed to validate Release Management Server for Team Foundation Server 2013.
at Microsoft.TeamFoundation.Release.CommonConfiguration.DeployerConfigurationManager.ValidateAndConfigure(DeployerConfigUpdatePack updatePack, DelegateStatusUpdate statusListener)
at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
A quick look using WireShark showed it was try to access http://releasemgmt.mydomain.com:1000/configurationservice.asmx,if I tried to access this in a browser it showed
Server Error in ‘/’ Application.
Request format is unrecognized.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Request format is unrecognized.
Turns out the issue was I needed to be run the deployment client configuration tool as the shadow user account, not as any other local administrator.
Once I did this the configuration worked and the management console could scan for the client. So now I can really start to play…
The TFS Community Build Extensions provide many activities to enhance your build. One we use a lot is the one for StyleCop to enforce code consistency in projects as part of our check in & build process.
In most projects you will not want a single set of StyleCop rules to be applied across the whole solution. Most teams will require a higher level of ‘rule adherence’ for production code as opposed to unit test code. By this I don’t mean the test code is ‘lower quality’, just that rules will differ e.g. we don’t require XML documentation blocks on unit test methods as the unit test method names should be documentation enough.
This means each of our projects in a solution may have their own StyleCop settings file. With Visual Studio these are found and used by the StyleCop runner without an issue.
However, on our TFS build boxes what we found that when we told it to build a solution, the StyleCop settings file in the same folder as the solution file was used for the whole solution. This means we saw a lot of false violations, such as unit test with no documentation headers.
The workaround we have used to not tell the TFS build to build a solution, but to build each project individually (in the correct order). By doing this the StyleCop settings file in the project folder is picked up. This is an OK solution, but does mean you need to remember to add new projects and remove old ones as the solution matures. Easy to forget.
Why is it like this?
Because of this on our engineering backlog we have had a task to update the StyleCop task so it did not use the settings file from root solution/project folder (or any single named settings file you specified).
I eventually got around to this, mostly due to new solutions being starting that I knew would contain many projects and potentially had a more complex structure than I wanted to manage by hand within the build process.
The issue is the in the activity a StyleCop console application object is created and run. This takes a single settings file and a list of .CS files as parameters. So if you want multiple settings files you need to create multiple StyleCop console application objects.
Not a problem I thought, nothing adding a couple of activity arguments and a foreach loop can’t fix. I even got as far as testing the logic in a unit test harness, far easier than debugging in a TFS build itself.
It was then I realised the real problem, it was the StyleCop build activity documentation, and I only have myself to blame here as I wrote it!
The documentation suggests a way to use the activity
- Find the .sln or .csproj folder
- From this folder load a settings.stylecop file
- Find all the .CS files under this location
- Run StyleCop
It does not have to be this way, you don’t need to edit the StyleCop activity, just put in a different workflow
A better workflow?
The key is finding the setting files, not the solution or project files. So if we assume we are building a single solution we can use the following workflow
This solution seems to work, you might get some files scanned twice if you have nested settings files, but that is not a issue for us as we place a StyleCop settings file with each projects. We alter the rules in each of these files as needed, from full sets to empty rulesets of we want StyleCop to skip the project.
So now I have it working internally it is now time go and update the TFS Community Build Extensions Documentation
Rik has just done a post on upgrading our SCVMM 2012 instance we use with Lab Management to 2012 R2, a good few gotchas in there as you might expect.
Well worth a read
I have just had a guest blog post published on the Microsoft UK Developers site ‘Migrating a TFS TFVC based team project to a Git team project retaining as much source and work item history as possible’. It discusses alternatives to using TFS Integration Platform to migrate source code and associated work items.