简体   繁体   中英

MSBuild and multiple Delphi versions

I have a project for which I need to build two executables: one under Delphi XE2 and one under XE3. I have a build script which builds each version (ie one script for XE2 and one for XE3).

If I run the build script for the last version of the IDE I ran, all works well (ie run Delphi XE2, build app, run XE2 build script).

However if I run the build script having just run a different version of the IDE I get an AV as soon as my app starts (Ie run Delphi XE2, built app, run XE3 build script).

It looks as though something about the build script is being cached/modified by the IDE and I need to restore the appropriate data for the version I want to build with. I've tried this with the .dproj, but no luck.

Or could it be loading form resources - both editions show errors due to non-existent properties at start up if the IDE. If so, is there an easy way around this without having maintain multiple versions of all the .fmx files?

Here's a sample build script:

set path=%path%;c:\Windows\Microsoft.NET\Framework\v3.5
set path=%path%;c:\Program Files (x86)\Embarcadero\RAD Studio\10.0
set path=%path%;c:\Documents and Settings\All Users\Documents\RAD Studio\10.0
set BDS=c:\Program Files (x86)\Embarcadero\RAD Studio\10.0
set FrameworkDir=c:\Windows\Microsoft.NET\Framework\
set FrameworkVersion=v3.5

set failed=false
cd \myprogs\monkeystyler
msbuild monkeystyler.dproj /t:build /p:config=full||set failed=true
cd build
if not %failed%==true goto Done

echo ****FAILED TO BULD MONKEYSTYLER
****
Pause
exit

:done

Let's take a look at this line in your XE3 script:

set path=%path%;c:\Program Files (x86)\Embarcadero\RAD Studio\10.0

My guess is that you follow that up in the XE2 script with:

set path=%path%;c:\Program Files (x86)\Embarcadero\RAD Studio\9.0

At which point your path variable looks like this:

set path=%path%;c:\Program Files (x86)\Embarcadero\RAD Studio\10.0;c:\Program Files (x86)\Embarcadero\RAD Studio\9.0

And so the second script fails because the paths from the first script appear earlier.

The elegant way to fix this is to use setlocal and endlocal in your scripts to isolate them from each other.

setlocal
set path=%path%;c:\Windows\Microsoft.NET\Framework\v3.5
set path=%path%;c:\Program Files (x86)\Embarcadero\RAD Studio\10.0
.....
endlocal

The hacky way to fix it is to set the path like this:

set path=c:\Program Files (x86)\Embarcadero\RAD Studio\10.0;%path%

Please use the elegant approach!


What's more you should use pushd and popd to isolate directory changes to each script.

If this doesn't solve everything, do give more information. For a start, error messages are very useful.

The last IDE that you run will update the EnvOption.proj in your <user>\\AppData\\Roaming\\Embarcadero\\BDS\\<version> folder.

This contains all your search paths, among other things.

This file is indirectly included in your project. So if you run say XE2's IDE then compile your XE3 app, you will get the wrong paths.

You will probably want to disable that and explicitly specify your search paths in each project's dproj file.

eg msbuild myproj.proj /p:ImportEnvOptions=false

This is my best guess. Sorry if it's 5 years too late. I have just struggled with similar issues!

All the best

Steve

I went back to my suspicion that it was the form file resources.

My theory was that the with the form files saved by the 'wrong' version of the IDE, when a project built with a different version tried to load them I was getting access violations due to the app trying to load data for properties which where not available in that edition.

To test this I got compiled the project successfully in one version of the IDE (XE3 in this case), did my automated build and tested that the app ran (it did).

I then loaded a .fmx file for the project and added a non-existent property to the form.

Build and the app fails same as before.

Remove the added property and build now succeeds.

All (!) I need to do now is write some code to parse the form files and remove any non-existent properties for the version I'm building.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM