MSB6001

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.

[md] error MSB6001: Invalid command line switch for “VCBuild.exe”. Item has already been added. Key in dictionary: ‘tmp’ Key being added: ‘tmp’
[/md]

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:

[md] > env
TEMP=/tmp
temp=path
tmp=path
TMP=/tmp

[/md]

Cygwin automatically sets the TEMP and TMP variables which it treats separate from the temp and 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:

[md] unset TMP
unset TEMP
[/md]

2 Replies to “MSB6001”

  1. Dude, thank you so much for this! I would have never imagined this was the problem. Thanks again! have a great day.

  2. I have visual studio 2015 and windows 10 and I’ve been getting the same error while trying to build a win 32 console application project. Do you have any idea how I can resolve this error?

Leave a Reply

Your email address will not be published. Required fields are marked *

*