I've created a custom MSBuild .targets
file that I've included in a Delphi XE project via the IDE and enabled it from the Project Manager's context menu. Although the file validates, it always gets disabled after I re-save the project file.
Here's a simplified version of the targets file, named Custom.targets
.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Hello">
<Message Text="Hello from custom target"/>
</Target>
</Project>
As a stand alone file this works as expected: typing...
MSBuild Custom.target /t:Hello
...at the command line gives the expected message.
Adding Custom.targets
to a Delphi project via the IDE displays the file in the Project Manager as expected, and the .dproj
file now contains the line...
<TargetsFile Include="Custom.targets"/>
I right-clicked the file in the IDE's Project Manager and selected Enable
. But when the project is built the Build
message window displays:
[MSBuild Warning] Custom.targets(1): Ignoring disabled import:
PathToProjectSource\\Custom.targets
Right-clicking again in Project Manager still shows the Enable
option instead of the expected Disable
.
At the command line MSBuild ProjectName.dproj /t:Hello
also fails.
I've tried hacking the .dproj
file to add the line...
<Import Project="Custom.targets"/>
Typing MSBuild ProjectName.dproj /t:Hello
now works. But the next time I save the project file from the IDE the <Import>
statement gets removed.
Anyone got any idea what's going wrong please?
/t:Hello
as well as from the IDE with right-click in the Project Manager - Targets - Hello. I've addedCustom.targets
to the project by right-clicking in the Project Manager - Add - (browsed for the file). The path is the same directory as the .dproj file. – Ondrej Kelle