What are the challenges you face when working across database platforms? Take the survey

Why is my ReadyRoll powershell deployment in VSTS failing with 'sqlcmd.exe' is not recognized?

griff182ukgriff182uk Posts: 9 New member
I am attempting to do an elastic pool database release using powershell with ReadyRoll, where the schemas and migrations are kept in synch across multiple shards that I just loop though. It works from my machine (doh!) but as soon as I call the powershell from as a task from VSTS I get the dreaded "'sqlcmd.exe' is not recognized" error. 
I've tried downloading ReadyRoll build components before the task in the release to see if that would help but to no avail. 
I have a similar process setup with dacpac deployment which works fine, but I'd like to use ReadyRoll for this.
Any help much appreciated while I continue to investigate. 


  • Options
    griff182ukgriff182uk Posts: 9 New member
    p.s it is running on hosted agent VS2017
  • Options
    griff182ukgriff182uk Posts: 9 New member
    not sure if there will be a better answer... but I deployed one of the shards using ReadyRoll deploy task and then did the rest via the powershell loop. Works fine :) 
    I'm guessing SqlCmd.exe gets imported as part of the ReadyRoll deploy task, which then allows the powershell to work. 
    I'll mark this as answer if nothing better comes along. 
  • Options
    Thank you for reporting this problem. I've now logged this defect internally (VSTS Extension issue #106). I notice that it has also been reported on StackOverflow with the following workaround:

    1. In the release definition, insert a PowerShell Script task (Type: Inline)
    <div>$sqlcmd = "C:\Program Files\Microsoft SQL Server\110\Tools\Binn";
    <span style="background-color: transparent; color: inherit; font-size: inherit; font-family: Roboto, "Helvetica Neue", Arial, sans-serif;">Write-Host "##vso[task.setvariable variable=PATH;]${env:PATH};${sqlcmd}";</span>
    2. Adjust the step order so that the new task executes prior to the ReadyRoll Deploy Database Package task

    I've confirmed that this works with the Hosted VS2017 agent.

    Apologies for the inconvenience. I'll update this thread once the team have had a chance to investigate this.
    Daniel Nolan
    Product Manager
    Redgate Software
Sign In or Register to comment.