1

I need to build a solution from the command line using msbuild with one of the arguments taking an environment variable as part of the argument, however the variable is not expanding when it is executed.

The command line I am using is

c:\windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /nologo "c:\b\sources\mysolution.sln" /m:1 /p:SkipInvalidConfigurations=true /p:VCBuildToolPath="$(VS80COMNTOOLS)....\VC\VCPACKAGES" /p:OutDit="C:\b\binaries\" /p:Configuration="RELEASE" /p:Platform="Mixed Platforms" /p:VCBuildOverride="C:\b\sources\mysolution.sln.mixed platforms.Release.vsprops"

and the error I receive is MSB6004: The specified task executable location "$(VS80COMNTOOLS)....\VC\VCPACKAGES\VCBuild.exe" is invalid. [c:\b\sources\mysolution.sln]

I have tried using double double quotes around the VCBuildToolPath argument, and using %VS80COMNTOOLS%, but the environment variable is never expanded.

According to the system VS80COMNTOOLS is set as c:\Program Files\Microsoft Visual Studio 8\Common7\Tools

Please could you tell me the syntax for using an environment variable in a command line argument in this way.

P.S. I do not what to have to revert to using an msbuild project file for this as I have a large number of solutions to which I need to apply this command line argument, across a number of build definitions all being triggered and built through TFS.

MikeW
  • 1,568
  • 2
  • 19
  • 39
  • *I do not what to have to revert to using an msbuild project file for this as I have a large number of solutions to which I need to apply this command line argument, across a number of build definitions* this sounds *exactly* as something you'd normally use MsBuild for though ? – stijn Feb 10 '14 at 11:58
  • I do wish to use msbuild, however I do not want to use and msbuild project to configure this, only command line switches. The build is performed via TFS2010, so I am specifying the arguments in the MSBuild Arguments option of the build definition – MikeW Feb 10 '14 at 12:13
  • In your command prompt type "set". Do you see an env var for VS80COMNTOOLS? If not, run vcvars32.bat (somewhere in your Visual Studio folder) then see if that env var is present. – Nicodemeus Feb 11 '14 at 06:43
  • the environment variable is present, that is not the problem, if I run this command from the command prompt (run->cmd.exe) it executes perfectly well, however if I use TFS to start the build (I am using a customized version of the default TFS build template) with the /p:VCBuildToolPath specified in the MSBuild Arguments of the build process parameters, the environment variable is not expanded – MikeW Feb 11 '14 at 07:59
  • When you say you're using TFS, are you sending this to a build server to perform the build? – Nicodemeus Feb 12 '14 at 02:31
  • yes, we are running tfs 2010, this is part of an automated build process, the problem stems from a requirement for a build server capable of supporting code written in vs2005 (c++ and c#.net2), vs2008 (c#.net3.5 and biztalk), vs2010 (c++ and c#.net4), and vs2012 (c#.net4.5) with the potential for .net4.51 project in vs2013 soon. MSbuild from .net 4 tries to use the vcbuild from vc9 by default, so need the switch to force it to use the vc8 version. In addition I want to support 32 and 64 bit build servers with a change to build definition, so need the env variable to locate the vc8 version. – MikeW Feb 12 '14 at 06:39
  • yes, sending to a build server – MikeW Feb 18 '14 at 13:15

0 Answers0