Comparing with MSBuild

I experienced some problems with a schema compare "project versus database".

The results are displayed in the window "Schema Update Script", but when "exporting to Editior" DBPRo tries to save the file with a name like "SchemaUpdate_<dbname>_<#>.sql" (# is a number).

Our databases have several "\" in the name. This is not nice, but we cannot change that for the tool. (We have a very large organisation with lots of projekts and the naming convention is very old.)


Because of this, it is not possible for us to save the results of the schema compare. Exporting to file return an error, too.

This is a great pity. Can you please use another naming convention for the file name, e.g. "SchemaUpdate_<#>.sql"?

[841 byte] By [ThomasGl?rfeld] at [2008-1-10]
# 1

This is a bug on our side. I have entered the issue into our bug database. I'm unable to come up with a workaround at this point other than to suggest manually saving the update script after copying it from the script window (not an elegant workaround, I readily admit, but one that at least persists the data Smile)

Thank you for bringing this issue to our attention.

JeffWeltonMSFT at 2007-10-3 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Database Professionals...
# 2
Hi Jeff,
thanks for entering the issue into your bug database. As you allready guessed I use the copy&paste solution as a workaround. But I really would like to use the regular functions.

(For some unknown reasons I was not able to record a replayable makro as a proper workaround. I got errors when running the recorded makro. But I presume this is only my problem and is not your concern. I wrote it only to illustrate how important the "save" feature is for me.)

Kind regards

Thomas

ThomasGl?rfeld at 2007-10-3 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Database Professionals...
# 3

Can't you choose to export to a file from the dropdown and choose your own name?

jdn at 2007-10-3 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Database Professionals...
# 4

No, this results in a message box with title "Microsoft Visual Studio". It has only ths text:

VSIP_FileSelectionSaveArgument('InitialFileName')

When clicking "OK" the message box is closed. I presume the init of the file selection dialog is aborting.

ThomasGl?rfeld at 2007-10-3 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Database Professionals...
# 5

Hi,

I just checked these issues with SR1:

The bugs are still not fixed. That is a great pity.

Please do not forget this feature.

Bye,

Thomas

ThomasGl?rfeld at 2007-10-3 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Database Professionals...
# 6

I got this working by using the new PowerTools, and the command-line version of SchemaCompare with MSBuild. I escape the slashes in the database name with the Hex code, as indicated in:

How To: Escape Special Characters in MSBuild

http://msdn2.microsoft.com/en-us/library/ms228186(vs.80).aspx

This doesn't yet do Projects versus actual databases but may help you?

Steps to Reproduce (make sure DBPro Power Tools are installed):

1) SQL script to create test databases with forward slashes in name:

Code Snippet

USE master

GO

CREATE DATABASE db1

GO

CREATE DATABASE db2

GO

EXEC sp_rename db1, [db1/1], 'DATABASE'

EXEC sp_rename db2, [db2/1], 'DATABASE'

GO

USE [db1/1]

GO

CREATE TABLE dbo.test1 ( test_id INT IDENTITY PRIMARY KEY )

GO

USE [db2/1]

GO

CREATE TABLE dbo.test1 ( test_id NUMERIC(9) IDENTITY PRIMARY KEY )

GO

2) testSchemaCompare.proj file in my %temp% directory.

Code Snippet

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--Import the settings-->
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0\TeamData\Microsoft.VisualStudio.TeamSystem.Data.PowerTools.Tasks.targets"/>

<Target Name ="SchemaCompare">

<SqlSchemaCompareTask
SourceConnectionString="Data Source=(local)\SQLSERVER2005;Integrated Security=True;Pooling=False"
SourceDatabaseName="db1%2F1"
TargetConnectionString="Data Source=(local)\SQLSERVER2005;Integrated Security=True;Pooling=False"
TargetDatabaseName="db2%2F1"
OutputPath = "$(temp)"
OutputFileName = "TestSchemaCompare.sql"/>

</Target>

</Project>

3) Executing MSBuild from the Visual Studio command-prompt as follows:

Code Snippet

MSBuild %temp%\testSchemaCompare.proj /t:SchemaCompare

That then successfully produces the output script despite the slashes in the database name. Hopefully this will help you!

Let me know how you get on or if you need any further information.

wBob at 2007-10-3 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Database Professionals...
# 7

Thanks for your sample. I was very busy so I could not test it earlier, sorry. I was so happy when I could run the test, but i got an error. Sorry.

Code Block
c:\temp\testSchemaCompare.proj(3,11): error MSB4019: The imported project "C:\Programme\MSBuild\Microsoft\VisualStudio\v8.0\TeamData\Microsoft.VisualStudio.TeamSystem.Data.PowerTools.Tasks.target" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.


When I looked in the directory "C:\Programme\MSBuild\Microsoft\VisualStudio\v8.0\TeamData" there was only one file: Microsoft.VisualStudio.TeamSystem.Data.Tasks.targets
So the error was right: The file "Microsoft.VisualStudio.TeamSystem.Data.PowerTools.Tasks.target" was not there.
I installed the powertools a second time (I clicked "repair" in the first window) and had to reboot my system. But still the file is missing, a search did not found it anywhere on my computer.
I am using a german Window XP SP2. Perhaps the installation is trying to copy it to "program files" instead of "programm"? Any other ideas?
May I download that file somewhere?

Kind regards

Thomas

ThomasGl?rfeld at 2007-10-3 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Database Professionals...
# 8

This is why you should never use a full path but use the MSBuild property $(MSBuildExtensionsPath)

There is an example project in your %ProgramFiles%\Microsoft Visual Studio 8\DBPro\PowerTools directory named SqlSchemaCompareTask.proj which shows you how to use this:

Code Block

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--Import the settings-->
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0\TeamData\Microsoft.VisualStudio.TeamSystem.Data.PowerTools.Tasks.targets"/>

<Target Name ="SchemaCompare">

<SqlSchemaCompareTask
SourceConnectionString="Data Source=(local)\sql90;Integrated Security=True;Pooling=False"
SourceDatabaseName="pubs"
TargetConnectionString="Data Source=(local)\sql90;Integrated Security=True;Pooling=False"
TargetDatabaseName="pubs2"
OutputPath = "$(temp)"
OutputFileName = "TestSchemaCompare.sql"/>

</Target>

</Project>

-GertD`

GertDrapers-MSFT at 2007-10-3 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Database Professionals...
# 9
Thanks for your answer. I am sorry for not posting the code.

Because I was answering Bobs posting, I thought it clear that i was nearly exactly using his example. This is the code I used. I changed only the server and database names:

Code Block

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--Import the settings-->
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0\TeamData\Microsoft.VisualStudio.TeamSystem.Data.PowerTools.Tasks.targets"/>

<Target Name ="SchemaCompare">

<SqlSchemaCompareTask
SourceConnectionString="Data Source=(local)\DATEV_CL_DE01;Integrated Security=True;Pooling=False"
SourceDatabaseName="db1%2F1%5C1"
TargetConnectionString="Data Source=(local)\DATEV_CL_DE01;Integrated Security=True;Pooling=False"
TargetDatabaseName="db2%2F1%5C1"
OutputPath = "$(temp)"
OutputFileName = "TestSchemaCompare.sql"/>

</Target>

</Project>

This resulted in the message:

Code Block
c:\temp\testSchemaCompare.proj(3,11): error MSB4019: The imported project "C:\Programme\MSBuild\Microsoft\VisualStudio\v8.0\TeamData\Microsoft.VisualStudio.TeamSystem.Data.PowerTools.Tasks.target" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

The replacement of "$(MSBuildExtensionsPath)" by "C:\Programme\MSBuild" was done by the tool. And that is the correct replacement on a german Windows. I presumed there should be an file named "Microsoft.VisualStudio.TeamSystem.Data.PowerTools.Tasks.target" in directory %ProgramFiles%\MSBuild\Microsoft\VisualStudio\v8.0\TeamData\" but there is not. The directory exists, but contains only one file "Microsoft.VisualStudio.TeamSystem.Data.Tasks.targets". A "repair installation" changed nothing.
I checked with a colleague who installed the Power Tools last week: on his system the file is not there, too.

Can you confirm if the file should be in "%ProgramFiles%\MSBuild\Microsoft\VisualStudio\v8.0\TeamData\", please?

If so, can I download it somewhere?

ThomasGl?rfeld at 2007-10-3 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Database Professionals...
# 10

I tested the sample that Gerd mentioned and it reslted i the same message:

Code Block

C:\Programme\Microsoft Visual Studio 8\VC>MSBuild "C:\Programme\Microsoft Visual Studio 8\DBPro\PowerTools\SqlSchemaCompareTask.proj" /t:SchemaCompare
Microsoft (R) Build Engine Version 2.0.50727.832
[Microsoft .NET Framework, Version 2.0.50727.832]
Copyright (C) Microsoft Corporation 2005. All rights reserved.

C:\Programme\Microsoft Visual Studio 8\DBPro\PowerTools\SqlSchemaCompareTask.proj(3,11): error MSB4019: The imported project "C:\Programme\MSBuild\Microsoft\VisualStudio\v8.0\TeamData\Microsoft.VisualStudio.TeamSystem.Data.PowerTools.Tasks.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

ThomasGl?rfeld at 2007-10-3 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Database Professionals...
# 11

Weird the file is not there. It's a bit of a kludge, but it's only a small file, so I'll include it here, maybe you can recreate it?

Code Block

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
'>http://schemas.microsoft.com/developer/msbuild/2003">http://schemas.microsoft.com/developer/msbuild/2003">
; <UsingTask TaskName="Microsoft.VisualStudio.TeamSystem.Data.PowerTools.Tasks.SqlDataCompareTask" AssemblyName="Microsoft.VisualStudio.TeamSystem.Data.PowerTools.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<UsingTask TaskName="Microsoft.VisualStudio.TeamSystem.Data.PowerTools.Tasks.SqlSchemaCompareTask" AssemblyName="Microsoft.VisualStudio.TeamSystem.Data.PowerTools.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</Project>

Dunno if I should be posting that PublicKeyToken ?

Also, my MSBuild number is:

Microsoft (R) Build Engine Version 2.0.50727.42

wBob at 2007-10-3 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Database Professionals...
# 12

We have a problem in the Power Tools installer, if you have a second or third big drive, the Power Tools setup will actually create a new Program Files\MSBuild directory on the drive with the most space. The only thing in there is the targets files, just move that to where your normal Program Files\MSBuild directory lives.

-GertD

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

Did you get this working Thomas?

Any chance you could rate the post if it works for you.

Thanks

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

Visual Studio Team System

Site Classified