2017-08-28 58 views
0

我的下面的代碼有什麼問題?我正在嘗試編寫一個批處理文件來發佈一個數據庫項目。如果我硬編碼修補程序和文件位置它工作正常。但一些我不能得到這個工作。 我得到的錯誤是連接變量和字符串批處理文件

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

我有下面的代碼目前。

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 
+2

您的問題不說出你的意思是「得到這個工作」,但一個明顯的問題是%ProfilePath%包含一個空格,而你沒有諷刺它。 – Joe

+0

@Joe:對不起。已經更新了現在的問題。 – ckv

+1

您是否嘗試過引用路徑:/ SourceFile:「%DACPACPath%」/ Profile:「%ProfilePath%」 – Joe

回答

1

命令

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

末創建一個空白字符稱爲SourceCodePath變量

因此,改變你的SET命令

SET SourceCodePath=C:\SourceCode\Dev\Code 
SET DACPACPath=%SourceCodePath%\Source\Data Service\SQL2014\bin\Debug\SQL2014.dacpac 
.... 
+0

我嘗試根據您的建議,但仍然得到相同的輸出。 – ckv

相關問題