Search code examples
c#windowsbatch-filebuild-events

C# Post Build Batch file returns '´╗┐'


I have a fairly large solution and in one of the project files in the Post Build I am executing a batch file.

The contents of which are:

echo %DevEnv%
echo %2
echo %1App-%DevEnv%.config
echo %1App.config
attrib -r %1App.config
copy %1App-%DevEnv%.config %1App.config 

rem We are also copying the machine specific config file to ECIHost too
echo %1
cd %1

echo attrib -r ..\ECIHost\ECIHost\App.config 
attrib -r ..\ECIHost\ECIHost\App.config 

echo copy App-%DevEnv%.config ..\ECIHost\ECIHost\App.config 
copy App-%DevEnv%.config ..\ECIHost\ECIHost\App.config 

The Post Build is:

"$(ProjectDir)CopyAppConfig.bat" "$(ProjectDir)" %DevEnv% >     "c:\build.txt"

I have also tried

cd "$(ProjectDir)"
CopyAppConfig.bat "$(ProjectDir)" %DevEnv% > "c:\build.txt"

Both return the same line:

'´╗┐' is not recognized as an internal or external command, operable program or batch file.

When I run the batch file from the console it echos and does everything successfully.

When I pipe to a file though I get the same as I do in the Output of my build window.

CopyAppConfig.bat > c:\temp\output.txt

In the output.txt file I get the output of the command but in the console window where I enter the command I get the same error.

It's not my machine, all developers have the same issue.

How can I fix this?


Solution

  • This looks like an encoding error.

    Batch files need to be ASCII... and you might have a UTF-8 with BOM.

    (The BOM is a byte-order-mark -- an optional header which says if the encoded file is big endian or little endian. Not everything handles these files properly.)