Oct 24, 2013 at 10:51 PM
Edited Oct 24, 2013 at 10:52 PM
I have been trying to use the SqlCmd class to attach a database and for some reason, I am constantly encountering this error message:
MSBUILD : warning 5120: Unable to open the physical file "C:\Database.mdf". Operating system error 5: "5(Access is denied.)". [C:\DevSolutionBuild.proj]
This is the MSBuild command that I am using:
<DNNAttachSQL>CREATE DATABASE $(DNNDatabaseName) ON ( FILENAME = N'$(DNNDataFile)' ),( FILENAME = N'$(DNNLogFile)' ) FOR ATTACH;</DNNAttachSQL>
<Message Text="$(DNNAttachSQL)" Importance="high" />
<MSBuild.ExtensionPack.SqlServer.SqlCmd TaskAction="Execute" Server="$(SqlServerName)" LogOn="$(SqlLogOn)" Password="$(SqlPassword)" CommandLineQuery="$(DNNAttachSQL)" />
The SQL executes just fine when I run it directly in SQL Server Management Studio and it succeeds in attaching the database, however, when I run it from within MSBuild, it always fails.
Please advise as to what I might be doing wrong.