2010-12-02 22 views
14

我實現斯科特Hanselman的方法與web.config中的開發/ QA/PROD版本跟上: http://www.hanselman.com/blog/CommentView.aspx?guid=93bfa4b3-44cd-4681-b70e-f4a2b0386466如何解決「@echo」是無法識別的命令

出於某種原因,當我編譯我的項目我在我的輸出窗口中收到此錯誤消息。
任何想法?

------ Build started: Project: ABC.Flims.Web, Configuration: Development Any CPU ------ 
"C:\Projects\ballyhoo-trunk\src\ABC.Flims.Web\scripts/copyifnewer.bat" "C:\Projects\ballyhoo-trunk\src\ABC.Flims.Web\web.config.Development" "C:\Projects\ballyhoo-trunk\src\ABC.Flims.Web\web.config" 
'@echo' is not recognized as an internal or external command, 
operable program or batch file. 

這裏是腳本文件:

@echo off 
echo Comparing two files: %1 with %2 

if not exist %1 goto File1NotFound 
if not exist %2 goto File2NotFound 

fc %1 %2 
if %ERRORLEVEL%==0 GOTO NoCopy 

echo Files are not the same. Copying %1 over %2 
copy %1 %2 /y & goto END 

:NoCopy 
echo Files are the same. Did nothing 
goto END 

:File1NotFound 
echo %1 not found. 
goto END 

:File2NotFound 
copy %1 %2 /y 
goto END 

:END 
echo Done. 

回答

28

的文件可能是採用Unicode編碼,並在被擺脫批處理器開始有Byte Order Mark(BOM)。

將它另存爲一個ASCII文件,你應該沒問題。您可以在notepad中執行此操作 - 從File菜單中選擇Save As...,並確保Encoding下拉列表設置爲ANSI

+1

此問題解決了我正在處理的Azure啓動問題。我使用的.cmd文件創建爲UTF-8而不是ANSI。以您建議的方式改變它解決了問題。 – Bern 2013-07-18 16:09:45

2

我認爲你的文件是Unicode編碼的,需要ascii。

1

發生類似問題。發現在Visual Studio中,如果你打開你的* .bat文件,你可以選擇文件 - >高級保存選項。從編碼下拉菜單中選擇'US-ASCII - Codepage 20127'

2

一個名爲echo的文件。

P:\>echo. 


P:\>dir /b echo 
File Not Found 

P:\>echo echo >echo 

P:\>dir /b echo 
echo 

P:\>echo. 
'echo.' is not recognized as an internal or external command, 
operable program or batch file. 

P:\>del echo 

P:\>dir /b echo 
File Not Found 

P:\>echo. 


P:\> 

當前文件夾或路徑中的回聲會導致此問題。

/echo