Watch, Follow, &
Connect with Us

Please visit our new home

Public Report
Report From: Delphi Prism/IDE/Project Management    [ Add a report in this area ]  
Report #:  89393   Status: Open
Issues extending the build process with more MSBuild targets
Project:  Embarcadero Prism Build #:
Version:    1.1 Submitted By:   Robert Ogren
Report Type:  Minor failure / Design problem Date Reported:  11/2/2010 9:44:14 AM
Severity:    Infrequently encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   281198
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Since the .oxygene project file is a standard MSBuild file, it should be possible to extend it with more MSBuild targets that are hooked into the build process, as described in the following articles:

This works fine if you build the project using MSBuild.exe from the command line, but not from the IDE (Visual Studio 2010 Shell). In the latter case, my added targets are not called. The problem is that the IDE seems to create a temporary copy of the project file, with the <Import> tags last, even though you need to put the setting of properties like CoreBuildDependsOn after importing the standard targets file(s). If you add files to the project and save it, then the rearranged tags are saved in the order the IDE wants them, so building from the command line stops working.

You can get around the problem by creating your own targets file and importing it after the standard targets file, but since the project seems to be loaded from a temporary file in a temp folder, you must specify an absolute path to the targets file.

Please make the IDE use the project file exactly as it is on disk. If it needs to be upgraded, then ask the user.
Steps to Reproduce:
Unpack the attached sample project. It contains the following lines AFTER <Import Project="$(MSBuildExtensionsPath)\RemObjects Software\Oxygene\RemObjects.Oxygene.targets" />

  <Target Name="MyBuildTarget" Outputs="$(ProjectDir)">
    <Message Text="Starting MyBuildTarget" Importance="high" />
    <WriteLinesToFile File="$(ProjectDir)" Lines="This is a generated file." Overwrite="true" />
  <Target Name="MyCleanTarget">
    <Message Text="Starting MyCleanTarget" Importance="high" />
    <Delete Files="$(ProjectDir)" />

It is supposed to generate when building, and remove it when cleaning.

Build it from the command line, from a command prompt in the project directory:

C:\windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe BuildActn.oxygene

Result: is created as expected

Clean the project from the command line:

C:\windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe BuildActn.oxygene /target:clean

Result: is deleted as expected

Make sure is not present. Open the project in the Visual Studio 2010 IDE and build. Result: is NOT created. There are no error messages.

You can try working around the problem by replacing the custom lines after <Import Project="$(MSBuildExtensionsPath)\RemObjects Software\Oxygene\RemObjects.Oxygene.targets" /> with this:

  <Import Project="MyBuild.targets" />

(There is already a MyBuild.targets with the correct lines, and another project file BuildActnImp1.oxygene with the changes made)

Building from the command line again works fine, while the IDE complains that 'The imported project "C:\Users\xxx\AppData\Local\Temp\MyBuild.targets" was not found' when trying to open the project.

Finally, if you change the <Import Project="MyBuild.targets" /> line to specify the full path to MyBuild.targets, then building and cleaning works both from the command line and the IDE.
Create your own targets file and import it after the standard targets file, using an absolute path to the targets file.


Server Response from: ETNACODE01