I'm trying to create a NuGet package that runs an external application before build. That application creates a compilationtime.h file to know the time of compilation to show it in the About dialog box.
My NuGet package has a Tools folder with the CreateCompilationTimeFile.exe and an Build folder with {packagename}.props file.
I've tried a lot of combinations to create the Pre-Build event in the {packagename}.props file but none of them is working.
I tried with this:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
<PreBuildEvent>
<Command>"$(MSBuildThisFileDirectory)..\tools\CreateCompilationTimeFile.exe"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
</Project>
Also with this:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="BeforeBuild2" BeforeTargets="Build">
<Exec Command="$(MSBuildThisFileDirectory)..\tools\CreateCompilationTimeFile.exe"/>
</Target>
</Project>
If I do it without the NuGet package and I do it with the next property sheet, it works correctly:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup>
<PreBuildEvent>
<Command>"$(SolutionDir)Tools\CreateCompilationTimeFile.exe"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup />
</Project>
But I want to do it with the NuGet package and not with property sheets.
What am I doing wrong? Thanks.