Monday, February 08, 2010

Be careful with comment location in pre/post deployment scripts

Just had a small issue with my SQL Database project.

In my Script.PostDeployment.sql file I put a standard SQL comment at the end of a line just to remind me of the required data load order;

:r LoadLookupTable.sql
:r LoadTestData.sql  -- Must load LookupTable first
When building the project this caused the following error;
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v9.0\TeamData\Microsoft.Data.Schema.SqlTasks.targets(80,5)Error MSB4018: The "SqlSetupDeployTask" task failed unexpectedly.System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path)
at System.IO.Path.IsPathRooted(String path)
at Microsoft.Data.Schema.Sql.Build.SqlDeploymentScriptModifier.GenerateMergedSqlCmdFiles(ContributorConfigurationSetup setup, ContributorConfigurationFile configFile)
at Microsoft.Data.Schema.Sql.Build.SqlDeploymentScriptModifier.OnEstablishDeploymentConfiguration(ContributorConfigurationSetup setup)
at Microsoft.Data.Schema.Build.DeploymentProjectBuilder.VerifyConfiguration()
at Microsoft.Data.Schema.Tasks.DBSetupDeployTask.BuildDeploymentProject(ErrorManager errors, ExtensionManager em)
at Microsoft.Data.Schema.Tasks.DBSetupDeployTask.Execute()
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)
Done executing task "SqlSetupDeployTask" -- FAILED.
By moving the comment to its own line like the following it then built correctly;
:r LoadLookupTable.sql
-- Must load LookupTable first
:r LoadTestData.sql
I know it's because it's being interpreted in SQLCMD mode but you'd think the parser would be smart enough to ignore it.

1 comments:

Wider Two Column Modification courtesy of The Blogger Guide