While Software Engineers are undoubtedly more familiar with the C#### or LNK#### errors generated by Visual Studio, MSB#### errors are more indicative of a problem with the compile or compile environment instead of with the code being compiled.
error MSB6001: Invalid command line switch for "VCBuild.exe". Item has already been added. Key in dictionary: 'tmp' Key being added: 'tmp'
While working on build automation using cygwin, I encountered a number of MSB6001 compile errors. They are generated due to a mismatch between how cygwin, being a linux shell, and the underlying Windows system, handle environment variables. We can see a selection of the currently set environment variables in cygwin:
> env TEMP=/tmp temp=path tmp=path TMP=/tmp ...
Cygwin automatically sets the
TMP variables which it treats separate from the
tmp variables already set by Windows. nmake, considering environment variables to be case-insensitive, considers them illegally redefined. This can be solved by unsetting cygwin’s automatically defined environment variables:
unset TMP unset TEMP