10

Is there a way to pass command line switches to devenv which are then passed as-is when it calls MSBuild?

Simone
  • 3,607
  • 1
  • 31
  • 37

2 Answers2

4

You definitely can achieve this for /property (/p) key of msbuild. Open .csproj in as text (with notepad.exe): all combinations like $(somename) are properties of msbuild. They can be passed in command line of msbuild via /p:somename=somevalue, but they also can be passed to devenv through environment variable. For example: start Visual Studio Command prompt, in the command prompt type:

set semename=somevalue

devenv

Visual Studio will start. Load a solution of your choice, the property "somename" will be passed to all projects in this solution with the value "somevalue".

farfareast
  • 2,179
  • 1
  • 23
  • 22
  • This is not working for me. I'm trying to pass the `OutputPath` property but devenv is ignoring it and putting the outputs in the default paths. – julealgon Sep 01 '14 at 15:32
  • @julealgon: `OutputPath` is not a property of MSBuild. It is not present in the form of $(OutputPath) in the csproj file. – farfareast Sep 23 '14 at 21:44
  • So how can you make this work with /p? set p=whatever? – Tsury Mar 25 '15 at 17:57
-2

Why don't you call MSBuild directly?

msbuild solution.sln /property:Configuration=Debug
Julien Hoarau
  • 48,964
  • 20
  • 128
  • 117