MSBuild 任务仅针对有更改的项目获取更新 FileAssemblyVersion

发布于 2024-09-13 05:19:55 字数 102 浏览 5 评论 0原文

有没有什么方法,使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

束缚m 2024-09-20 05:20:29

假设您已设置增量 [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 same Inputs 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 to FileAssemblyVersion, 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 the AssemblyVersion, which cant be tweaked after the fact in the same way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文