Problem:
Building project with console MSBuild sometimes causes an Error MSB3073: The command exited with code 1.
For example, simple exec msbuild task fails:
<exec Command=”echo HelloWorldMessage” />
This appears at msbuild.exe output as:
‘C:\Documents’ is not recognized as an internal or external command, operable program or batch file.
MSBuild wraps your command with a temporary bat file and stores it to the user Temp directory. Then MSBuild tries to execute your bat file with CMD. Usually, user Temp directory path starts with ‘C:\Documents and Settings\UserName’. So, first command CMD interpretation looks like ‘C:\Documents’.
Solution:
- Go to environment variables menu.
- Change TEMP and TMP variables to the values without spaces. For example, ‘C:\Temp’.
- Create new temp directory ‘C:\Temp’.