MSBuild : want to detect when files change for the target to be called
I am trying to write targets file that is imported by a project:
It doesn't call that target when i change the input files at all whatever i tried nothing.
The way i know if it actually happend is by looking at that timestamp file
Let me know if you need more context.
<ItemGroup>
<AssetFiles
Include="$(AssetsFullPath)/**/*"
Exclude="$(AssetsFullPath)/bin/*/**;$(AssetsFullPath)/obj/**/*;$(AssetsFullPath)/$(MGCBFileName)"/>
<AssetsDirItem
Include="$(AssetsFullPath)"/>
</ItemGroup>
<Target Name="FenzworkSetup" BeforeTargets="CoreCompile;BeforeBuild">
<PropertyGroup><AssetsTimestampFilePath>$(MSBuildProjectDirectory)/$(IntermediateOutputPath)assets_timestamp.cache</AssetsTimestampFilePath>
</PropertyGroup>
<ItemGroup>
<AssetsTimestamp Include="$(AssetsTimestampFilePath)"/>
</ItemGroup>
<Touch Condition="!Exists($(AssetsTimestampFilePath))"
Files="$(AssetsTimestampFilePath)"
AlwaysCreate="True"/>
</Target>
...
<Target Name="RunGenTool"
Inputs="@(AssetFiles)"
Outputs="@(AssetsTimestamp)">
<Message Text="Running GenTool..." Importance="High" />
<Touch Files="@(AssetsTimestamp)" AlwaysCreate="true" />
<Exec Condition="$(IsUsingSourceGenTool)"
Command="dotnet "$(GenToolDllPath)" build "%(AssetsConfig.Identity)" "%(AssetsDirItem.Identity)" "$(IntermediateOutputPath)"" />
</Target> <ItemGroup>
<AssetFiles
Include="$(AssetsFullPath)/**/*"
Exclude="$(AssetsFullPath)/bin/*/**;$(AssetsFullPath)/obj/**/*;$(AssetsFullPath)/$(MGCBFileName)"/>
<AssetsDirItem
Include="$(AssetsFullPath)"/>
</ItemGroup>
<Target Name="FenzworkSetup" BeforeTargets="CoreCompile;BeforeBuild">
<PropertyGroup><AssetsTimestampFilePath>$(MSBuildProjectDirectory)/$(IntermediateOutputPath)assets_timestamp.cache</AssetsTimestampFilePath>
</PropertyGroup>
<ItemGroup>
<AssetsTimestamp Include="$(AssetsTimestampFilePath)"/>
</ItemGroup>
<Touch Condition="!Exists($(AssetsTimestampFilePath))"
Files="$(AssetsTimestampFilePath)"
AlwaysCreate="True"/>
</Target>
...
<Target Name="RunGenTool"
Inputs="@(AssetFiles)"
Outputs="@(AssetsTimestamp)">
<Message Text="Running GenTool..." Importance="High" />
<Touch Files="@(AssetsTimestamp)" AlwaysCreate="true" />
<Exec Condition="$(IsUsingSourceGenTool)"
Command="dotnet "$(GenToolDllPath)" build "%(AssetsConfig.Identity)" "%(AssetsDirItem.Identity)" "$(IntermediateOutputPath)"" />
</Target>It doesn't call that target when i change the input files at all whatever i tried nothing.
The way i know if it actually happend is by looking at that timestamp file
Let me know if you need more context.