August 2007 - Posts

Moving to Wordpress

I've decided to move this blog to Wordpress.

I've appreciated Dotnetjunkies being my home for three years, but I feel it is not being maintained or updated. The community has also markedly slowed down a lot.

I've noted a lot of developers have started blogs on Wordpress, and I feel it is a pleasure to use, rather than fighting the Dotnetjunkies user interface. (To this day, I have no idea why comments will not work properly)

http://andrewwhitten.wordpress.com

I hope to have a higher profile with my new technology - Team Foundation Server - and I hope to see you there if you have an interest too :)

Visual Studio for Database Professionals can not use variables in build

I was happy to find that Visual Studio for DB Professionals (SP1) allowed you to add variables for your database scripts on a configuration level.

Great! I thought I could generate SQL scripts for my entire database depending on it being a production or test target. How useful!

Well.. not really...

As try as I might, I could not get those variables to appear in my SQL script.

I got an answer from the forums to say that basically this can ONLY be done when 'deploying' a database.. building one is apparently not reason enough for DB Pro to replace variables.

They said that the SQLCMD command might want to override variables, which is why they don't replace them during build.

I admit.. the 'deploy' functionality of DB Pro is great.. it is smooth and simple.

BUT I can not (nor would I ever) use it to deploy to a production database. For this task, I would generate a SQL script (via build) and give it to the production support team. I would never come close to touching that database.

So... basically this great feature is rendered useless...

I had to instruct my SQL script to examine the database name for environment variables

IF DB_NAME() == 'MyProductionDatabase'
BEGIN
INSERT ....
END

Run TFS Team Build with project from Team Edition for Database Professionals

I like Team Edition for Database Professionals... if you do ANY management of Sql Server databases then you should take a look and ask yourself if your life wouldn't be easier to use it.

I then thought "Wouldn't it be cool to build these database projects on TFS?"

Yeah.. it would, but it isn't as simple as it should be.

First problem: You need to install 'Team Edition for Database Professionals' on your Build machine.. messy, but not a show stopper.

Second Problem: Permissions.

If you have a good TFS Build Server, then your user should be a Windows Standard User.. and not a super God like user that you need to run anything without pain on a Windows machine.

1) First, identify your build user, for example: Hal-Domain\Dave

2) In the Sql Server 2005 management tool, assign Hal-Domain\Dave as dbcreator and securityadmin

3) Run the following sql as DBO:

USE MASTER

GO

GRANT EXECUTE ON sp_detach_db TO public

GO

GRANT VIEW SERVER STATE TO "Hal-Domain\Dave"
GO

A full overview of permissions can be found here

For search engines, the error was:

Microsoft.VisualStudio.TeamSystem.Data.Common.Exceptions.DesignDatabaseFailedException: You have insufficient permissions to create the database project.

Force refresh of TFS file status

It seems the hardest part of being a Team Foundation Server admin is the 'This is how things worked in Visual SourceSafe' way of thinking.

Well, today I came across a legitimate gripe.. the status icons of a file do not always update properly, even when you do a 'get latest'.

I found a way around it, but frankly this should be default behavior:

http://devmatter.blogspot.com/2007/07/refreshing-tfs-version-control-status.html

Hiding certain Team Builds for certain users

The good thing about MSDN Forums is that you get questions you may not otherwise ever think about, and by so doing you increase your knowledge about the subject.

One poster wanted to know how to 'hide' particular team builds from particular users, but allow them to execute other builds in the same Team Project in Team Foundation Server.

My initial feeling was that this wasn't possible, but a little experimenting proved me wrong:

If you have a Team Build called 'SecureBuild' you want to deny to the group [SERVER]\NormalDevs, do the following:

In 'Source Control Explorer', find your build project under .\TeamBuildTypes\SecureBuild\SecureBuild.proj

Right mouse click on MyBuild.proj and select 'properties...'

In the resultant dialog, click on the 'security' tab.

In the listed groups, choose the [SERVER]\NormalDevs group who you do not want to be able to build.

Simply set their 'Read' permission to 'Deny'

When they look in their 'Team Builds' in 'Team Explorer', 'SecureBuild' will no longer appear.

Adding an SMTP alerts server to TFS

I didn't have the information about the email server before setting up TFS, but figured it would be easy to set up afterwards.... wrong :)

Well, actually it *is* easy, but just isn't straightforward to find.

Find your TFS service web.config file.. on my machine it is here:

C:\Program Files\Microsoft Visual Studio 2005 Team Foundation Server\Web Services\Services\web.config

and add/adjust the following xml tags:

<appSettings>
<add key="ConnectionString" value="Application Name=TeamFoundation;Persist Security Info=False;Initial Catalog=TfsIntegration;Data Source=xxxxx;Integrated Security=SSPI"/>
<add key="eventingEnabled" value="true" />
<add key="DetailedExceptions" value="false" />
<add key="emailNotificationFromAddress" value="andrew@xxxxxxxxxxxxx.com" />
<add key="smtpServer" value="smtp.mailserver.xxxxxxxxxxxxx.com" />
<add key="SmtpUserName" value="MyDomain\MyUser" />
<add key="SmtpPassword" value="MySecurePassword" />
</appSettings>