Domanda

sto cercando di fare alcune cose SQL (indietro di un database, ripristinare un database, eseguire alcuni file di script) come parte di uno script MSBuild. Il compito Sql2008.Database dal coro MSBuild estensione sembrava essere un modo semplice bella di fare questo, però non riesco a trovare un modo per specificare un'istanza del server o il nome utente e la password. Trovo difficile credere che si è limitata al caso di difetto sulla macchina che si sta costruendo e vuole connettersi come utente MSBuild è in esecuzione ma non riesco a trovare un modo per fare qualsiasi altra cosa. Questa è la documentazione che Sto lavorando da. Qualcuno può spiegare come fare questo o devo guardare un approccio diverso?

È stato utile?

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

Altri suggerimenti

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top