MSBuild is not set in the environment path

I’m trying to use msbuild.build to build a Delphi project. Unfortunately, I get the “MSBuild is not set in the environment path!” error.

I’ve also added the line
shell.exec(“c:/Program Files (x86)/Embarcadero/RAD Studio/9.0/bin/rsvars.bat”);
before calling msbuild.build, but that didn’t help either.

How should I set the MSBuild environment path properly and do I need to call rsvars.bat when using Train’s msbuild?

Thanks,
Vladimir Kudelin

Hi,

What you need to do is to make sure that the environment variable ‘MSBuild’ exists when running the Trains script.
I did that by added the variable to the system variables using the System properties in windows.
The variable should contain the path to MSBuild.exe
This is the content on my system:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe

Hi,

Yep, I’ve already found that (after looking at sources). Thanks anyway.

But now I have another issue. I’m calling:
msbuild.build(“d:/Foo/Bar.dproj”, {configuration: “Release”, platform: “Win32”});

… but get the following error:
C:\Program Files (x86)\Embarcadero\RAD Studio\9.0\bin\CodeGear.Common.Targets(
170,5): error : Invalid PLATFORM variable “Release”. PLATFORM must be one of the
following: “Win32”, “Win64”, or “OSX32”. If PLATFORM is defined by your system’
s environment, it must be overridden in the RAD Studio IDE or passed explicitly
on the command line to MSBuild; e.g., /p:Platform=Win32.
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.01

MSBuild failed

} msbuild.build
} script

Changing “configuration” to “Win32” makes things working, but that sounds wrong. And how can I control configuration itself (release, debug)?

Ok, seems like I found a bug.

MSBuild.pas, lines 176 and 222 say:

sb.Append(’ “/property:Platform=’+aOptions.configuration+’”’);

Shouldn’t it be:
sb.Append(’ “/property:Platform=’+aOptions.platform+’”’);

Hm… why it wasn’t for all except me?..

Carlo, if you can confirm the bug, could you please fix&rebuild Train for me?

Vladimir Kudelin

Fixed in git. Thanks!

Ok, I’ve rebuilt Train myself.

Along with fixing the above bug, I also has needed to change the property name form “/property:Configuration” to “/property:Config”.

Seems like Delphi’s projects requires “Config”, not “Configuration”. Just curious: how did you use Train in your building stuff before?

Hi Vladimir,

There is also a Delphi project builder class exposed in Train. (Delphi.build) I think RO uses that to build their Delphi Code. I use MSBuild, but I only have Oxygene code.

Jeroen,

Yeah, that explains my troubles with msbuild.

But how do you think, if changing Configuration to Config (required for Delphi projects) will be breakable for Oxygene, C#, etc?

Vladimir Kudelin.

That’s odd (delphi). The standard flag is configuration. but you can always use extraArgs:
msbuild.build(“d:/Foo/Bar.dproj”, {extraArgs: “/config:Release”, platform: “Win32”});

For anyone who will be facing issues, the correct usage would be:
{extraArgs: “/property:Config=Release”, platform: “Win32”}