SQL Server数据库项目:错误MSB4018“SqlDeployTask”

时间:2012-03-14 19:06:39

标签: visual-studio-2010 sql-server-2008 msbuild tfs2010 team-build

首先,我已经引用了以下帖子

VS2010 Database project deploy - "SqlDeployTask" task failed unexpectedly, NullReferenceException

http://social.msdn.microsoft.com/Forums/en/vstsdb/thread/e848f09f-5d5d-46d5-b27a-c7769b188c78

我有一个连接到Team Foundation Server的数据库项目。我已成功创建/修改表和过程并部署到数据库。有一次,我认为我的本地项目与TFS 之间存在同步问题(我可能忘记在签出之前检查更改)由于发生这种情况,我无法部署项目。我收到以下错误:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamData\Microsoft.Data.Schema.TSqlTasks.targets(120,5): Error MSB4018: The "SqlDeployTask" task failed unexpectedly.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Data.Schema.Sql.SchemaModel.SqlScriptDomGenerator.AlterStatementGenerator.GenerateStatement(IModelElement modelElement)
   at Microsoft.Data.Schema.Sql.Build.SqlDeploymentPlanGenerator.AlterStatementGeneratorBase.GenerateAlterProcedureStatement(IModelElement oldElement, IModelElement newElement)
   at Microsoft.Data.Schema.Sql.Build.SqlDeploymentPlanGenerator.AlterStatementGeneratorBase.GenerateStatement(IModelElement oldElement, IModelElement newElement)
   at Microsoft.Data.Schema.Sql.Build.SqlDeploymentPlanGenerator.AlterStatementGeneratorBase.GenerateScriptDom(IModelElement oldElement, IModelElement newElement)
   at Microsoft.Data.Schema.Sql.Build.SqlDeploymentPlanGenerator.DeploymentScriptDomGenerator.GenerateFragment(Int32 operation, IModelElement element)
   at Microsoft.Data.Schema.Sql.Build.SqlDeploymentPlanGenerator.DeploymentScriptDomGenerator.GenerateSteps(Int32 operation, IModelElement element)
   at Microsoft.Data.Schema.Sql.Build.SqlDeploymentPlanGenerator.OrderedStepGenerator.Add(DeploymentScriptDomGenerator scriptDom, IModelElement element, Int32 operation)
   at Microsoft.Data.Schema.Sql.Build.SqlDeploymentPlanGenerator.PlanMediator.BuildDependencyOrderedSteps(Int32 operation, List`1 classOrder, List`1 operationOrder, Dictionary`2 changes, Boolean preserveGraphs, Dictionary`2& relating, Dictionary`2& related)
   at Microsoft.Data.Schema.Sql.Build.SqlDeploymentPlanGenerator.PlanMediator.BuildOperations()
   at Microsoft.Data.Schema.Sql.Build.SqlDeploymentPlanGenerator.OnGeneratePlan()
   at Microsoft.Data.Schema.Build.DeploymentPlanGenerator.GeneratePlan()
   at Microsoft.Data.Schema.Build.SchemaDeployment.BuildPlan()
   at Microsoft.Data.Schema.Build.SchemaDeployment.Execute(Boolean executeDeployment)
   at Microsoft.Data.Schema.Build.SchemaDeployment.Execute()
   at Microsoft.Data.Schema.Tasks.DBDeployTask.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)
   Done executing task "SqlDeployTask" -- FAILED.
  Done building target "DspDeploy" in project "Ched 10.dbproj" -- FAILED.
 Done executing task "CallTarget" -- FAILED.
Done building target "DBDeploy" in project "Ched 10.dbproj" -- FAILED.
Done building project "Ched 10.dbproj" -- FAILED.

在上面的SO帖子中看起来问题是函数的问题。我只在项目中创建了一个函数,并尝试将其从数据库中删除,并重新部署项目失败。我继续进行故障排除,尝试上面MSDN帖子中列出的所有以下步骤:

1. Unloaded the project, deleted the *.dbmdl files, and reloaded project.
2. Switch project properties to just create a deploy script
3. Switch back to creating a deploy script and deploy
4. Cleaned the project

这些都不起作用,当我将项目设置为仅创建部署脚本而不是实际部署时,我仍然遇到了失败。

我已完成模式比较,并将数据库中的数据镜像到项目中的数据。查看MSDN文章中的解决方案,用户最终在重构日志中发现错误。我查看了重构日志并查看可能存在问题的位置,但是我找不到如何解决它。重构日志包含数据库或项目中不存在的条目(这些是已从项目中完全删除的表或过程)

关于如何解决这个问题的任何想法?


不确定这是否有帮助,但这是我的重构日志:

<?xml version="1.0" encoding="utf-8"?>
<Operations Version="1.0">
  <Operation Name="Rename Refactor" Key="b38ad5f3-ed84-4796-aaa6-4021ae32238e" ChangeDateTime="01/31/2012 19:11:11">
    <Property Name="ElementName" Value="[dbo].[GetModule]" />
    <Property Name="ElementType" Value="ISql100Procedure" />
    <Property Name="ParentElementName" Value="[dbo]" />
    <Property Name="ParentElementType" Value="ISql90Schema" />
    <Property Name="NewName" Value="[GetModuleOutline]" />
  </Operation>
  <Operation Name="Rename Refactor" Key="7e984a2d-8251-4a78-9926-c11e9d3771a3" ChangeDateTime="01/31/2012 20:58:24">
    <Property Name="ElementName" Value="[dbo].[GetModuleOutline]" />
    <Property Name="ElementType" Value="ISql100Procedure" />
    <Property Name="ParentElementName" Value="[dbo]" />
    <Property Name="ParentElementType" Value="ISql90Schema" />
    <Property Name="NewName" Value="[GetModuleOutlineByID]" />
  </Operation>
  <Operation Name="Rename Refactor" Key="62d05d8a-1c45-4b32-94b2-2f0640e48c55" ChangeDateTime="01/31/2012 20:58:35">
    <Property Name="ElementName" Value="[dbo].[GetSectionOutline]" />
    <Property Name="ElementType" Value="ISql100Procedure" />
    <Property Name="ParentElementName" Value="[dbo]" />
    <Property Name="ParentElementType" Value="ISql90Schema" />
    <Property Name="NewName" Value="[GetSectionOutlineByID]" />
  </Operation>
  <Operation Name="Rename Refactor" Key="26fd6cbf-9a72-431b-8399-de3780150f1e" ChangeDateTime="02/01/2012 21:14:35">
    <Property Name="ElementName" Value="[dbo].[Tracker]" />
    <Property Name="ElementType" Value="ISql100Table" />
    <Property Name="ParentElementName" Value="[dbo]" />
    <Property Name="ParentElementType" Value="ISql90Schema" />
    <Property Name="NewName" Value="[StudentSlideProgress]" />
  </Operation>
  <Operation Name="Rename Refactor" Key="c1286fdd-08a7-43a0-b9ac-5137b08bc783" ChangeDateTime="02/01/2012 22:52:45">
    <Property Name="ElementName" Value="[dbo].[TrackerActionType]" />
    <Property Name="ElementType" Value="ISql100Table" />
    <Property Name="ParentElementName" Value="[dbo]" />
    <Property Name="ParentElementType" Value="ISql90Schema" />
    <Property Name="NewName" Value="[SlideActionType]" />
  </Operation>
  <Operation Name="Rename Refactor" Key="3d1fbdbb-9290-4400-9fba-04924f1ac5fd" ChangeDateTime="03/05/2012 22:37:51">
    <Property Name="ElementName" Value="[dbo].[GetStudentAuthentication]" />
    <Property Name="ElementType" Value="ISql100Procedure" />
    <Property Name="ParentElementName" Value="[dbo]" />
    <Property Name="ParentElementType" Value="ISql90Schema" />
    <Property Name="NewName" Value="[GetStudentVerification]" />
  </Operation>
  <Operation Name="Rename Refactor" Key="5d40b8e2-6466-4050-90be-d28d16ac2d86" ChangeDateTime="03/13/2012 18:38:58">
    <Property Name="ElementName" Value="[dbo].[SetStudentBegin]" />
    <Property Name="ElementType" Value="ISql100Procedure" />
    <Property Name="ParentElementName" Value="[dbo]" />
    <Property Name="ParentElementType" Value="ISql90Schema" />
    <Property Name="NewName" Value="[SetStudentSlideBegin]" />
  </Operation>
  <Operation Name="Rename Refactor" Key="5f2d4bd5-95d9-4b8f-91c5-46e89673c93b" ChangeDateTime="03/13/2012 19:01:55">
    <Property Name="ElementName" Value="[dbo].[SetStudentSlideBegin]" />
    <Property Name="ElementType" Value="ISql100Procedure" />
    <Property Name="ParentElementName" Value="[dbo]" />
    <Property Name="ParentElementType" Value="ISql90Schema" />
    <Property Name="NewName" Value="[SetStudentSlideStart]" />
  </Operation>
  <Operation Name="Rename Refactor" Key="f4b2ad86-46af-41e8-9d66-4f61bf78e481" ChangeDateTime="03/13/2012 19:14:27">
    <Property Name="ElementName" Value="[dbo].[SetStudentSlideEnd]" />
    <Property Name="ElementType" Value="ISql100Procedure" />
    <Property Name="ParentElementName" Value="[dbo]" />
    <Property Name="ParentElementType" Value="ISql90Schema" />
    <Property Name="NewName" Value="[SetStudentSlideStop]" />
  </Operation>
</Operations>

0 个答案:

没有答案