mac - visual studio set environment variables for debugging c#




How do I set Environment Variables in Visual Studio 2010? (2)

How do I set Environment Variables in Visual Studio 2010?

I found this web page.

Which says:

From the Project menu, choose Properties.

In the left pane, select Configuration Properties, and then select Environment.

But when I select "Configuration Properties", there is no "Enviroment" option:

This is an example in VS 2008:

But how is it done in VS 2010?


Simply add an eviroment variable in system. In command line SET VAR=VALUE Then pick it up with $(VAR)


You are comparing a C++ project in VS2008 to a C# project in VS2010. These two projects use different kind of build engine. VS2008 C++ project use a make-based build and use heavily environment variables. VS2010 (and VS2008 for that matter) C# projects use MSBuild and rarely (1) depend on environment variables.

Unless you have modified your .csproj file or have a custom build tool, changing environment variables should not be the way to do whatever you want to it is. If you describe your goal, we'll be able to better help you with advice how to achieve it.

Update: MSBuild can use environment vairables. However, VS does not provide an UI to set those for standard C# projects (even if you install earlier version). Most probably the build project you are looking at is intended to be build from the command line using msbuild.exe.

You have couple of options:

  • Open the .csproj file in Notepad and add to the <PropertyGroup> element the particular variable you need with the value you want to set. (properties set in a work for MSBuild like environment variables for Make)
  • If the environment variables are used only in the pre-build and post-build events, you can edit those in the Project properties, in the Build Events tab.
  • If you build from the command line using msbuild.exe, you can specify those properties on the command line, like this: msbuild /property:<name>=<value> ...
  • You can create a .settings file, which contains a with all the properties and then include it in all the .csproj files that need to share same values.
  • You can open a new command-prompt, set the environment variables in it and then launch VS from inside it. VS will pick up the environment from that command prompt.

(1) I was tempted to say "never", but I do have couple of projects where I want the build to depend on environment variables, mostly to enable automated builds on machines without .Net installed.





environment-variables