4

我在 VS 2010 中构建 TFS 之后运行这个 .bat 文件。但它抛出错误说“文件名目录名称或卷标语法不正确”

我的批处理文件包含以下内容:

REM "*******START :Modify the following sections*******"
call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86_amd64

set ProjectPath=C:\Builds\1\xxxx\xxx\Sources

Set PATH=%PATH%;%Windir%\Microsoft.NET\Framework\v4.0

REM  "------Move to the Project Folder------"
cd /c %ProjectPath%
cd  C:\Builds\1\xxx\xxxx\TestResults

REM  "------Find the latest Test Result file------"
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in ('dir/b/a-d/o-d "C:\Builds\1\xxx\xxxx\TestResults\*.trx"') do (
   set latesttrxfile=%%a & goto :done
)
:done

echo %latesttrxfile%

REM  "------Move to test results folder------"
cd C:\Builds\1\xxx\xxxx\TestResults

REM  "------Convert trx to html------"
trx2html "C:\Builds\1\xxx\xxxx\TestResults\%latesttrxfile%"

REM  "------Find the latest Test Result html file------"
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in ('dir/b/a-d/o-d "C:\Builds\1\xxx\xxx\TestResults\*.htm"') do (
   set latesthtml=%%a & goto :done
)
:done

echo %latesthtml%

REM  "------Send Email------"
sendEmail.exe -s xxx.xxx.xxx.com -f yyyy@xxx.com -t yyyy@xxx.com -u Test Report attached -a "C:\Builds\1\xxx\xxx\TestResults\%latesthtml%" -m TestReportAttached

Pause
4

1 回答 1

4

我发现问题在于我的批处理文件是 Unicode(似乎是 VS 2010 中的文本文件的默认设置)。

文件 > 高级保存选项并更改为西方修复了该问题。

于 2013-09-11T11:29:20.257 回答