MSBuild.ExtensionPack.SqlServer.SqlCmd throws InvalidOperationException: No process is associated with this object on TeamCity

Nov 20, 2013 at 6:27 PM
__I have a build script that works fine on local developer machines but throws the exception below when I execute the command on a TeamCity build server.

The command in the db.targets that's failing is:__
        <RebuildSqlScripts Include="$(RebuildDirectory)\*.sql"/>

    <Message Condition ="'%(RebuildSqlScripts.Filename)' != ''" Text="Executing SQL Scripts in $(RebuildDirectory) on $(DatabaseName): "/>
    <!--<Message Text="SQL Script Files: @(RebuildSqlScripts)"/>-->

    <MSBuild.ExtensionPack.SqlServer.SqlCmd Condition ="'%(RebuildSqlScripts.Filename)' != ''" TaskAction="Execute" LogExceptionStack="true" Server="$(SqlServerName)" Database="$(DatabaseName)" LogOn="$(User)" Password="$(Password)" InputFiles="%(RebuildSqlScripts.Identity)" Variables="@(DatabaseVariables)" />

The exception:

[MSBuild.ExtensionPack.SqlServer.SqlCmd] C:\BuildAgent1\work\700df50f30b3154c\build\Database\Common\db.targets(97, 3): InvalidOperationException: No process is associated with this object.
at System.Diagnostics.Process.EnsureState(State state)
at System.Diagnostics.Process.get_HasExited()
at MSBuild.ExtensionPack.SqlServer.Extended.SqlCmdWrapper.Execute() in C:\Projects\CodePlex\MSBuildExtensionPack\Solutions\Main\Framework\SqlServer\SqlCmdWrapper.cs:line 105
at MSBuild.ExtensionPack.SqlServer.SqlCmd.ExecuteCommand(String arguments) in C:\Projects\CodePlex\MSBuildExtensionPack\Solutions\Main\Framework\SqlServer\SqlCmd.cs:line 480
at MSBuild.ExtensionPack.SqlServer.SqlCmd.SqlExecute() in C:\Projects\CodePlex\MSBuildExtensionPack\Solutions\Main\Framework\SqlServer\SqlCmd.cs:line 559
at MSBuild.ExtensionPack.BaseTask.Execute() in C:\Projects\CodePlex\MSBuildExtensionPack\Solutions\Main\Common\BaseTask.cs:line 85

Any idea what the error actually means? I looks like the underlying exception is being suppressed...
Nov 29, 2013 at 1:09 PM
Hmmm.... I 'know' why this is happening, I just need to think about the best fix... Will get back to you... I'll also copy this to a workitem.

Nov 29, 2013 at 1:10 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Nov 29, 2013 at 1:34 PM
Please let me know it the private build files i attached to the workitem work.
Marked as answer by mikeFourie on 1/14/2014 at 6:47 AM
Jan 28, 2014 at 8:52 PM
I'm having this same problem and I can test this private build. But what version of Extension Pack does this dll replace? I have the October edition, but is this 3.5 or 4.0?

Also, is there any work-around (anything I can change on the server) as an interim solution?
Jan 28, 2014 at 10:26 PM
Hi, the fix is for 4.0