Sql2008 Restore using Move syntax doesn't support secondary data files

Jan 11, 2010 at 3:28 AM

It appears that Sql2008 Restore doesn't support secondary data files when using the NewDataFilePath / LogFilePath syntax in place to support RESTORE WITH MOVE.

I've been poking at the code to try to figure out how to patch it, but haven't been able to figure out how to debug MSBEP tasks / task actions. I'm happy to work on a patch if someone could provide guidance on debugging, hitting breakpoints, etc. I've searched extensively today, to no avail.

Jan 11, 2010 at 12:36 PM


To debug an MSbuild task, go to the Properties of your project.

  • Click the Debug tab.
  • For Start Action, select 'Start external program' and enter C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe
  • For Start Options, enter the path to your .proj file
  • Set your project as the Startup project.
  • Put a breakpoint in your code, e.g. on the InternalExecute method.
  • Hit F5.


Jan 11, 2010 at 4:17 PM

Hi Mike,

Yes, these directions are similar to what I've found online. What's unclear to me is: what is the appropriate project for these startup customizations?

I've downloaded the code from the latest changeset, and have loaded Releases\\Main3.5\MainSolution.sln. I've done the following:

  1. Set these customizations on the Sql2008 project, pointing to a project file containing the following:
    <Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    	<UsingTask AssemblyFile="$(MSBuildProjectDirectory)\..\Sql2008\obj\Debug\MSBuild.ExtensionPack.Sql2008.dll" TaskName="MSBuild.ExtensionPack.Sql2008.Database"/>
    		<OSFilePath>C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\</OSFilePath>
    	<Target Name="BeforeBuild">
    		<!-- Restore a database to a different location-->
  2. Set a breakpoint on line 646 of Database.cs:
    sqlRestore.Devices.AddDevice(this.DataFilePath.GetMetadata("FullPath"), DeviceType.File);
  3. Set Sql2008 as startup project, and hit F5.

Sadly, the breakpoint is not hit. Any additional guidance you might provide would be greatly appreciated. FYI, in addition to submitting a patch for the secondary data file issue (if I can get moving on this issue), I'll gladly write up whatever details it takes for me to get debugging working, for inclusion in future documentation.




Jan 11, 2010 at 5:53 PM

Hi Stuart

1. Is $(MSBuildProjectDirectory)\..\Sql2008\obj\Debug\MSBuild.ExtensionPack.Sql2008.dll definitely the output of the project, i.e. are you in debug configuration and

2. Do you see a flash of a command window?

3. Can you run MSBuild.exe "pathtoyourfile" successfully? Note you will need quotes if your path has spaces.

I'll contact you offline for a speedier resolution and we can post the final solution here...




Jan 15, 2010 at 7:37 PM

Restarting VS fixed this issue :-)