开发者

MSBuild ExtensionPack Sql2008.Database task

I am trying to do some SQL stuff (back a database, restore a database, run some script files) as part of an MSBuild script. The Sql2008.Database task from the MSBuild Extensio开发者_Python百科n pack seemed to be a nice easy way of doing this, however i cannot find a way to specify a server instance or username and password. I find it hard to believe that it is limited to the default instance on the machine you are building on and want to connect as the user MSBuild is running but i can't find a way to do anything else. This is the documentation I am working from. Can anyone explain how to do this or do i need to look at a different approach?


There are UserName and UserPassword properties you can use:

<MSBuild.ExtensionPack.Sql2008.Database 
MachineName="$(SQLServer)" 
TaskAction="Backup" 
DatabaseItem="$(SQLDatabaseName)" 
DataFilePath="$(SQLBackupLocation)" 
UserName="$(SQLUserName)"
UserPassword="$(SQLPassword)" />


I discovered that the MSBuild.ExtensionPack.BaseTask class has the properties MachineName UserName and UserPassword. SQL2008.Database class inherits from this class. I am used to MSDN style documentation where the inherited members are documented on the derived class so i did not think to look for them there although i should have. It does seem a strange place for them though as they are meaningless in the context of many of the other classes that inherit from MSBuild.ExtensionPack.BaseTask.


Doesnt that task have the MachineName member? Think thats just the sql instance name you need.

I use the task MSBuild.ExtensionPack.SqlServer.SqlExecute and a sql statement to do everything else e.g.

<MSBuild.ExtensionPack.SqlServer.SqlExecute TaskAction="ExecuteReader"
                                                Sql="RESTORE DATABASE $(DatabaseName) FROM  DISK = N'$(RestoreFileDestination)\Source\$(Branch)\Build\$(DatabaseFile)' WITH FILE = 1,MOVE N'Accelerate' TO N'$(dataDir)\$(DatabaseName)_1.LDF', MOVE N'Accelerate_log' TO N'$(logsDir)\$(DatabaseName)_2.LDF', NOUNLOAD, REPLACE, KEEP_CDC, STATS = 10"
                                                ConnectionString="Data Source=Localhost\SQLExpress;Initial Catalog=master;Integrated Security=True"
                                                CommandTimeout="660">

They'd never think of all the options i seem to need....

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜