SteveNel

Hi all,

Is there a pre-defined variable that I can reference in the post-deployment scripts that contains the location of the DB Pro project This is what I'd like to do in the post-deployment script:

Tongue Tiedetvar ProjectRoot -- what to put here

EXEC [dbo].[spjjk_DatabaseMaintenance__LoadAll] '$(ProjectRoot)\MyFolder'

Each developer will have their own local workspace for the DB Pro project, and it may be in a different location for each developer. Suppose the project is called "MyDatabase". Some developers may have the project in this location "c:\dev\MyDatabase", whereas other developers use this other location "d:\files\local\dev\MyDatabase". I do not want to declare a specific variable in the deployment script that is hard-wired to a specific folder. How can I declare this variable so that it detects where the actual project is being loaded from

In the above example, how can I construct the variable $(ProjectRoot) so that it contains the fully qualified folder path of the MyDatabase project

In the MSBuild world, I think there is a variable called "SolutionRoot", and that's close to what I'm looking for, but when I use that in a post-deployment script, it's not available.

Any ideas on the best way to do this

--steve



Re: Visual Studio Team System - Database Professionals Variable for solution location available for use in deployment scripts

Jamie Laflen MSFT

You should reference the TargetDir MSBuild property to correctly derive the output directory; this way, it will work in scenarios like TeamBuild where the output is redirected.

To create a SqlCmd variable that contains the full path you would do something like this:

In .dbproj:

<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0\TeamData\Microsoft.VisualStudio.TeamSystem.Data.Tasks.targets" />

<PropertyGroup>

<SetVariables>

<Variable Name="OutDirFullPath" Value="$(TargetDir)" />

</SetVariables>

</PropertyGroup>

In post script:

print 'Output full path: $(OutDirFullPath)'

Note that the TargetDir MSBuild property is defined during processing in the Microsoft.Common.targets file so our SetVariables MSBuild property must be defined after the .targets inport.






Re: Visual Studio Team System - Database Professionals Variable for solution location available for use in deployment scripts

SteveNel

Jamie,

Thanks, that works great! I noticed that the $(TargetDir) maps to the "sql" directory for the project. I assume that under the covers this really maps to the "Build Output Path" set on the property page of the project.

In order to get at the "Scripts" directory of the project I was able to do this:

Code Snippet
<PropertyGroup>
<SetVariables>
<Variable Name="ScriptPath" Value="$(TargetDir)\..\Scripts\" />
</SetVariables>
</PropertyGroup>

Is there a different variable that maps directly into the project root, or do I need to use a relative-reference from $TargetDir, as I did in the example above.

If I wanted to learn more about what variables I had access to, how could I do that Is there a documented list of all MSBuild variables that can be referenced I assume that the $TargetDir is actually declared in the Microsoft.VisualStudio.TeamSystem.Data.Tasks.targets code, how would I learn what else is defined in there

Thanks!

--steve





Re: Visual Studio Team System - Database Professionals Variable for solution location available for use in deployment scripts

Jamie Laflen MSFT

Hi Steve,

Yes, the sql directory is the directory in the projectí»s build properties.

I think that ultimately it might be better to reference data that is in the output directory rather than in the source directory, this way, if someone would like to copy the output to another machine/location the output will still work. You could copy the directory you would like to reference as part of a pre-build step by using the build event. That said, if you would like the full path to the project directory you could use $(MSBuildProjectDirectory)

We do define some database specific properties in the .targets file you mention, but for what you are looking for you really want to look at Microsoft.Common.targets (in for example C:\Windows\Microsoft.NET\Framework\v2.0.50727). Some additional documentation:

MSBuild

http://msdn2.microsoft.com/en-us/library/wea2sca5(VS.80).aspx

MSBuild Reference

http://msdn2.microsoft.com/en-us/library/0k6kkbsd.aspx

MSBuild Reserved Properties

http://msdn2.microsoft.com/en-us/library/ms164309.aspx