1

In order to include environment variables in a VS2010 project build I run this in the VS2010 Command Prompt

devenv myProject.sln /build "DeBug" /useenv

and get the error

Invalid Command Line. Unknown Switch : useenv

I cannot see where I am going wrong.

Luca
  • 9,259
  • 5
  • 46
  • 59

1 Answers1

0

Navigate to path where your Visual Studio is installed. On my local it is: C:\Program Files (x86)\Microsoft Visual Studio 10.0\

Go to Common7\IDE directory: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE and open console here.

Now, run the following command in the commnad prompt: devenv -h

It will list all available parameters and switches of the devenv.exe. On the bottom of the output, there should be the following:

Product-specific switches:

/debugexe Open the specified executable to be debugged. The
    remainder of the command line is passed to this
            executable as its arguments.

/useenv Use PATH, INCLUDE, LIBPATH, and LIB environment variables
            instead of IDE paths for VC++ builds.

I assume you will get shorter list, without the /useenv option, something like:

Product-specific switches:

/debugexe       Open the specified executable to be debugged. The
    remainder of the command line is passed to this
            executable as its arguments.

That's the reason why you always get "invalid command line. unknown switch: useenv" error message.

I had the same issue and did the following to fix it:

  1. If you have .NET framework 4.5 installed, Uninstall it.
  2. Uninstall Visual Studio 2010
  3. Install .NET framework 4.0 before you install Visual Studio 2010 again (do not install .NET 4.5)
  4. Install Visaul Studio 2010.
  5. Now you can install .NET 4.5

I did not have enough time to investigate and to explain 'why'. But these steps sorted this issue out.