MSBuild 任务仅针对有更改的项目获取更新 FileAssemblyVersion
有没有什么方法,使用 msbuild 或其他方式来检测哪些项目在当前构建中发生了更改,并仅更新这些项目的 AssemblyInfo.cs 中的 FileAssemblyVersion 属性?
Is there any way, using msbuild or otherwise, to detect which projects have changes in the current build and update the FileAssemblyVersion attribute in AssemblyInfo.cs for those projects only?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您已设置增量 [get 和] 编译,下一步将是挂钩到 MSBuild 序列。查看
FrameworkDir\Microsoft.Common.Targets
。问题是,事情并没有设置为以这种方式工作 - 事实上,有_TimestampBeforeCompile
和_TimeStampAfterCompile
步骤,这只是表明您无法先验地确定某些事情即将编译。虽然理论上您可以在 [特定语言] CoreCompile [例如,在 Microsoft.CSharp.targets 中] 之前挂钩,但问题是您需要具有与它相同的Inputs
才能确定如果发生这种情况,这将意味着大量的剪切和粘贴并与系统文件保持同步。另一件需要警惕的事情是在_ComputeNonExistentFileProperty
目标顶部的注释中指出的。因此,除了对序列进行一些非常深入的修改之外(例如,如果您的自定义
_TimeStampAfterCompile
检测到发生了编译,则挂钩“构建后”位会强制进行第二次编译)我想说没有简单的、推荐的或受支持的方法。话虽如此,
AssemblyFileVersion
(您指的是FileAssemblyVersion
,它不存在:P)在编译后很容易修改。因为它只是一种资源 - 但我假设您实际上正在谈论同时执行它和AssemblyVersion
,事后无法以相同的方式对其进行调整。Assuming you've set up incremental [get and] compiles, the next step would be to hook into the MSBuild sequence. Have a look in
FrameworkDir\Microsoft.Common.Targets
. The problem is that things just are not set up to work in this way - the fact that there are_TimestampBeforeCompile
and_TimeStampAfterCompile
steps which just show that you cant determine a priori if something is going to compile. While you could theoretically hook in before [the language specific] CoreCompile [e.g., in Microsoft.CSharp.targets], the problem would be that you need to have the sameInputs
as it does in order to determine if its going to happen, which would mean lots of cut and pasting and keeping in sync with system files. The other thing to be wary of is noted in the comment at the top of the_ComputeNonExistentFileProperty
target.So, outside of doing some very deep modifications to the sequence (e.g., hooking in a 'post build' bit which forces a second compile if a custom
_TimeStampAfterCompile
of yours detects that a compilation took place, I'd say there's no easy, recommended or supported way.Having said that, the
AssemblyFileVersion
(you refer toFileAssemblyVersion
, which doesnt exist :P) is easy to modify after the compile as its just a resource - you'll find tools for that. But I assume you're really talking about doing both it and theAssemblyVersion
, which cant be tweaked after the fact in the same way.