What I'm trying to accomplish is detecting changes to projects during build so I can set a flag indicating that the project was changed. I've already figured out how to detect when a C# component has changed by utilizing incremental builds and CoreCompileDependsOn. But this doesn't seem to trigger when a content file of a project has changed. From what I understand, there would be a Copy task somewhere specifying SkipUnchangedFiles="true" depending on the setting of the content file within the project, Copy to Output Directory (Do not copy, Copy Always, Copy if Newer). I'm not entirely sure where this process happens, possibly the Microsoft.CSharp.targets file? Could someone please advise as to how I would add a dependent task that executes only if an updated file was copied to the bin output? A very simple example would suffice.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I figured it out. This will write a text file with the name of the project ONLY if any content files that have 'Copy If Newer' set have been changed during a build:
<Target Name="ContentFilesUpdated" AfterTargets="_CopyOutOfDateSourceItemsToOutputDirectory" Condition="'$(IsDesktopBuild)' == 'False'">
<WriteLinesToFile
File="@(ProductChangeFile)"
Lines="$(ProjectName)"
Overwrite="false"
Encoding="Unicode" Condition="!Exists('@(ProductChangeFile)')"/>