visual-studio 如何解决“@echo”不是公认的命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4337445/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 12:50:45  来源:igfitidea点击:

How do I resolve '@echo' is not a recognized command

asp.netvisual-studiovisual-studio-2008

提问by Mike Roosa

I've implemented Scott Hanselman's method for keeping up with a dev/qa/prod version of web.config: http://www.hanselman.com/blog/CommentView.aspx?guid=93bfa4b3-44cd-4681-b70e-f4a2b0386466

我已经实施了 Scott Hanselman 的方法来跟上 web.config 的 dev/qa/prod 版本:http: //www.hanselman.com/blog/CommentView.aspx?guid=93bfa4b3-44cd-4681-b70e-f4a2b0386466

For some reason when I compile my project I get this error message in my output window.
Any ideas?

出于某种原因,当我编译我的项目时,我在输出窗口中收到此错误消息。
有任何想法吗?

------ 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.  

Here is the script 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.

回答by Oded

The file is probably Unicode encoded and has a Byte Order Mark(BOM) at the start that is throwing off the batch processor.

该文件可能是 Unicode 编码的,并且在开始时有一个字节顺序标记(BOM),这会导致批处理器失效。

Save it as an ASCII file and you should be OK. You can do this in notepad- select Save As...from the Filemenu and ensure that the Encodingdropdown is set to ANSI.

将其另存为 ASCII 文件,您应该没问题。你可以这样做notepad选择-Save As...File菜单中,确保Encoding下拉菜单设为ANSI

回答by StephanJW

Stumbled upon a similar issue. Found that within visual studio, if you open your *.bat file, you can choose File -> Advanced Save Options. From the drop-down menu under encoding, select 'US-ASCII - Codepage 20127'

偶然发现了一个类似的问题。发现在visual studio中,如果你打开你的*.bat文件,你可以选择File -> Advanced Save Options。从编码下的下拉菜单中,选择“US-ASCII - Codepage 20127”

回答by Suresurep

A file named echo.

一个名为 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:\>

An echo in current folder or in the path will cause this.

当前文件夹或路径中的回声会导致这种情况。

/echo

/回声

回答by Lou Franco

I think your file is Unicode encoded and needs to be ascii.

我认为你的文件是 Unicode 编码的,需要是 ascii。