TSD151: SQL Execution error: A fatal error occurred. Variable USERDOMAIN could not be found.

Hello,

I am trying to deploy and unit test a DB Pro project using Team Build. I have followed several articles scattered around the web to get the configurations correct for connection strings and projects paths and everything was working great. For a time.

I have recently added an IF block to one of the DB Pro project's post-deployment scripts that tests for our domain and creates a new user:

IF '$(USERDOMAIN)' = 'MYDOMAIN'

BEGIN

// CREATE USER ... FOR LOGIN ...

END

GO

This portion of the script executes fine in these environments:

* Deploy DB Pro project from local dev machine in Visual Studio.

* Run tests against database (which deploys first) on local machine in VS.

* Deploy DB project from as part of Team Build on server.

But it fails with the error specified in the Subject of this post when running tests against the database as part of Team Build on the server.

Can I expect to be able to access environment variables from within my DB Pro project like this? Is there a workaround for this problem?

Thanks,

- Jason

[1135 byte] By [jstangroome] at [2008-1-10]
# 1

What is the service account of the Team Build service?

If this ia LocalSystem, NetworkService or LocalService it does not have these enviroment variables defined, hence the failure.

If the build service runs under a domain account the variable should be there.

-GertD

GertDrapers-MSFT at 2007-10-3 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Database Professionals...

Visual Studio Team System

Site Classified