Visual Studio中插入在批处理文件无效字符 [英] Visual Studio inserts invalid characters in batch files

查看:425
本文介绍了Visual Studio中插入在批处理文件无效字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,我用它来帮助自动创建和重装数据库发展的过程中的一些批处理文件。这是有道理的创建和维护(在VS数据库项目即)在Visual Studio这些批处理文件。他们看起来pretty简单,像这样的:

I've got some batch files that I use to help automate the process of creating and reloading development databases. It makes sense to create and maintain these batch files in Visual Studio (i.e., in a VS Database project). They look pretty simple, like this:

@echo off
echo Setting server and db from defaults.
set SERVERNAME=(LOCAL)
set DB=PLEDGES
echo Creating tables on server %SERVERNAME% and database %DB%
sqlcmd -S %SERVERNAME% -d %DB% -E -i DropAllTables.sql
sqlcmd -S %SERVERNAME% -d %DB% -E -i dbo.UserType.Table.sql
sqlcmd -S %SERVERNAME% -d %DB% -E -i dbo.RegisteredUser.Table.sql
echo Done creating tables.

问题是,当我运行它们,这是输出:

The problem is that when I run them, this is the output:

C:\>
'' is not recognized as an internal or external command,
operable program or batch file.
Creating tables on server (LOCAL) and database PLEDGES
Done creating tables.

在换句话说,Visual Studio是莫名其妙无形中插入字符集的Windows命令处理器间preting作为一个命令,即∩╗┐。谷歌搜索返回在这个什么都没有。有其他人遇到这个?在修复的思考?

In other words, Visual Studio is somehow invisibly inserting a set of characters that the Windows command processor is interpreting as a command, i.e., "". A Google search returned nothing on this. Has anybody else run into this? Thoughts on a fix?

我有一种变通方法(只需添加一个空行到每个文件的开头,它会显示错误,但除此之外,做工精细),舍我其谁的肛门保持侧被我每次运行时恼火这些文件中的一个。

I've got a workaround (just add a blank line to the beginning of each file, and it'll show the error, but otherwise work fine), but the anal-retentive side of myself gets annoyed each time I run one of these files.

推荐答案

正在发生的事情是,VisualStudio中正在被巧妙的事实,您的批处理文件已保存在非ASCII字符编码躲在你(例如,您的文件是UTF-8或其他一些非ASCII编码)。

What is happening is that VisualStudio is being clever and hiding you from the fact that your batch-file has been saved in a non-ASCII character encoding (e.g. your file is UTF-8 or some other non-ASCII encoding).

我的项目团队已被这一抓出了几下(如果文件被放入CVS它使文件的混乱)。

My project team has been caught out a few times by this (if the files are checked into CVS it makes the files a mess).

我倾向于使用记事本+ +,看看在右下角的编码(应该说,这是ANSI),如果你需要改变它转到格式菜单,改变类型,然后保存。

I tend to use Notepad++, look at the encoding on the lower-right (it should say that it is ANSI), if you need to change it go to the format menu and change the type then save.

Visual Studio中看起来应该相同,但文件大小应减半!

Visual Studio should look identical but the file size should have halved!

这篇关于Visual Studio中插入在批处理文件无效字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆