0

What is wrong with my below code? I am trying to write a batch file to publish a Database project. If I hard code the patch and file locations it works fine. But some how I am not able to get this working. The error I get is

*** Argument 'SourceFile' has an invalid value: ''.
*** Argument 'Profile' has an invalid value: ''.

I have the following code currently.

SET SourceCodePath = "C:\SourceCode\Dev\Code"
SET DACPACPath = %SourceCodePath%\Source\Data Service\SQL2014\bin\Debug\SQL2014.dacpac
SET ProfilePath = %SourceCodePath%\Data Service\SQL2014\SQL2014.Local.publish.xml
ECHO %ProfilePath%
ECHO %DACPACPath%
"c:\Program Files (x86)\Microsoft SQL Server\120\dac\bin\SqlPackage.exe" /Action:Publish /SourceFile:%DACPACPath% /Profile:%ProfilePath%
PAUSE
6
  • 2
    Your question doesn't say what you mean by "get this working", but one obvious problem is that %ProfilePath% contains a space, and you haven't quoted it. Commented Aug 28, 2017 at 7:34
  • @Joe: Yes Sorry for that. Have updated the question now. Commented Aug 28, 2017 at 8:13
  • 1
    have you tried quoting the paths: /SourceFile:"%DACPACPath%" /Profile:"%ProfilePath%" Commented Aug 28, 2017 at 8:43
  • @Joe: Yes. I have tried that also but I get same error. Should be something silly but not able to figure out. Commented Aug 28, 2017 at 8:48
  • Try prefixing the last line with "ECHO ". This will echo the command that's failing instead of executing it. You can then try running it manually until you work out what's wrong. Commented Aug 28, 2017 at 9:02

1 Answer 1

3

the command

SET SourceCodePath = "C:\SourceCode\Dev\Code"

creates a variable called SourceCodePath with a blank character at the end

so, change your SET commands to

SET SourceCodePath=C:\SourceCode\Dev\Code
SET DACPACPath=%SourceCodePath%\Source\Data Service\SQL2014\bin\Debug\SQL2014.dacpac
....
Sign up to request clarification or add additional context in comments.

1 Comment

I tried based on your suggestion but still I am getting the same output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.