我关注How to prepare database for TFS deployment walkthrough
我的构建脚本在构建过程结束时成功部署了数据库。但是,我需要在运行单元测试之前部署数据库。 我尝试复制步骤并将其粘贴在“获取受影响的测试,索引源和发布符号”上方。但是,构建过程会返回以下错误:
* 部署清单文件Database_Core.deploymanifest不存在 以下是我的xaml文件摘录数据库部署:
<Sequence DisplayName="Deploy Database" sap:VirtualizedContainerService.HintSize="486,330">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
<x:Boolean x:Key="IsPinned">True</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<If Condition="[BuildDetail.CompilationStatus <> BuildPhaseStatus.Failed]" DisplayName="If Build Succeeded" sap:VirtualizedContainerService.HintSize="464,206">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsPinned">True</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<If.Then>
<mtbwa:InvokeProcess Arguments="["/a:Deploy /cs:""Data Source=MyServer-SQL1\BUILD;Integrated Security=True;Pooling=False"" /dd+ /dsp:Sql /manifest:Database_Core.deploymanifest"]" DisplayName="Invoke VSDBCMD" FileName="C:\Program Files (x86)\Microsoft Visual Studio 10.0\VSTSDB\Deploy\VSDBCMD.EXE" sap:VirtualizedContainerService.HintSize="219,100" WorkingDirectory="[BuildDetail.DropLocation]">
<mtbwa:InvokeProcess.ErrorDataReceived>
<ActivityAction x:TypeArguments="x:String">
<ActivityAction.Argument>
<DelegateInArgument x:TypeArguments="x:String" Name="errOutput" />
</ActivityAction.Argument>
<mtbwa:WriteBuildError DisplayName="VSDBCMD Error" sap:VirtualizedContainerService.HintSize="200,22" Message="[errOutput]" />
</ActivityAction>
</mtbwa:InvokeProcess.ErrorDataReceived>
<mtbwa:InvokeProcess.OutputDataReceived>
<ActivityAction x:TypeArguments="x:String">
<ActivityAction.Argument>
<DelegateInArgument x:TypeArguments="x:String" Name="stdOutput" />
</ActivityAction.Argument>
<mtbwa:WriteBuildMessage DisplayName="VSDBCMD Output" sap:VirtualizedContainerService.HintSize="200,22" Importance="[Microsoft.TeamFoundation.Build.Client.BuildMessageImportance.High]" Message="[stdOutput]" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" />
</ActivityAction>
</mtbwa:InvokeProcess.OutputDataReceived>
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsPinned">False</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</mtbwa:InvokeProcess>
</If.Then>
<If.Else>
<mtbwa:WriteBuildWarning DisplayName="Deployment Skipped" sap:VirtualizedContainerService.HintSize="220,100" Message="Database deployment was skipped" />
</If.Else>
</If>
</Sequence>
答案 0 :(得分:0)
您可以更改部署中发生这种情况的位置。
我会在工作流程中的主构建命令之后立即部署数据库。在2008年,.proj更加清晰,因为您只需将其添加到<Target Name=BeforeTest>
尝试将其移至过程中的早期点。
答案 1 :(得分:0)
这正是我所需要的。请参阅here描述以下所有要点的PNG:
左侧MSBuild的参数(“运行MSBuild + Deploy DB”):
String.Format("/p:SkipInvalidConfigurations=true /t:Build;Deploy /p:TargetConnectionString=""Data Source={0}%3Buser={1}%3Bpwd={2}"" /p:DeployToDatabase=true /p:TargetDatabase={3}_{4} {5}",
TargetMachineToDeployDB, DBUsername, DBPassword, DBName, BuildDetail.BuildNumber.Replace(".", "_"), MSBuildArguments)
如果它不太明显,参数和&amp;之间的连接。定义中显示的参数是:
- TargetMachineToDeployDB =“应部署数据库的PC名称”
- DBUsername =“数据库用户名”
- DBPassword =“数据库密码”
- DBName =“数据库前缀名称”(我连接当前的构建名称)
右侧的MSBuild参数(“为SLN / Project运行MSBuid”):
String.Format("/p:SkipInvalidConfigurations=true {0}", MSBuildArguments)
请注意,如果我在左侧部署了数据库,我还会将 DBHasBeenSet 设置为TRUE,这也会在“源文件中的适应”中触发一些文件处理。这些包括将我们的NUnit DLL重定向到新构建的数据库。如果您愿意,我可以设置更多细节。