문제

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 Extension 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?

도움이 되었습니까?

해결책 2

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.

다른 팁

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)" />

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....

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top