Is there a good tutorial for Creating a database using msbuild?
jean paul boodhoo does it using nant in this post. he sets properties to be used in an nant build file
<properties>
<property name="sqlToolsFolder" value="C:\Program Files\Microsoft SQL Server\90\Tools\Binn"/>
<property name="osql.ConnectionString" value="-E"/>
<property name="initial.catalog" value="Northwind"/>
<property name="config.ConnectionString" value="data source=(local);Integrated Security=SSPI;Initial Catalog=${initial.catalog}"/>
<property name="database.path" value="C:\root\development\databases" />
<property name="osql.exe" value="${sqlToolsFolder}\osql.exe" />
</properties>
then can create the database using the command line like this..
c:\> build builddb
I installed the MSBuild Extension pack but I could not find where to enter the connection string to connect to the database
Thanks
RESOLVED
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="constants.proj"/>
<Target Name="QueryDb">
<PropertyGroup>
<_Command>-Q "SELECT * FROM Users"</_Command>
<_Command2>-i test.sql</_Command2>
</PropertyGroup>
<Exec Command="$(sqlcmd) $(_Command)" /><!---->
</Target>
</Project>
and Constants.proj looks like this
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<sqlToolsFolder>C:\Program Files\Microsoft SQL Server\90\Tools\Binn</sqlToolsFolder>
<initialCatalog>NorthwindTest</initialCatalog>
<serverInstance>(local)\SQLEXPRESS</serverInstance>
<configConnectionString>data source=$(serverInstance);Integrated Security=SSPI;Initial Catalog=$(initialCatalog)</configConnectionString>
<osqlExe>"$(sqlToolsFolder)\osql.exe"</osqlExe>
<sqlcmd>$(osqlExe) -U someuser -P somepassword -d $(initialCatalog) -S (local)\SQLEXPRESS</sqlcmd>
<!--<sqlcmd>$(osqlExe) -E -d $(initialCatalog) -S (local)\SQLEXPRESS</sqlcmd>-->
</PropertyGroup>
</Project>
then at the vs command prompt run
msbuild db.targets /t:QueryDb
the command that runs is this "C:\Program Files\Microsoft SQL Server\90\Tools\Binn\osql.exe" -U someuser -P somepassword -d NorthwindTest -S (local)\SQLEXPRESS -Q "SELECT * FROM UserProfile"
Thank you Sayed