Visual Studio 添加始终运行的预生成事件(C# 项目) [英] Visual Studio add pre-build event that always runs (C# project)

查看:88
本文介绍了Visual Studio 添加始终运行的预生成事件(C# 项目)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我正在运行一个外部工具来更新一些二进制文件.这些文件作为内容"包含在项目中.

In my project, I am running an external tool to update some binary files. These files are included in the project as "content".

目前该工具设置为在 C# 项目属性中的预构建事件"期间运行.不幸的是,只有在项目过期时才会执行此事件,这不是我所需要的.

At the moment the tool is set to run during "pre-build event" in C# project properties. Unfortunately, this event is only executed if the project is out of date, which is not what I need.

我一直在我的项目中使用重建"而不是构建"来解决这个问题,但这既乏味又缓慢.

I am working around this by always using "rebuild" instead of "build" on my project, but this is tedious and slow.

无论项目是否是最新的,我都需要始终执行此工具.实际上,甚至在MSBuild之前甚至还没有判断项目是否是最新的,因为该工具修改了项目中包含的一些文件,从而影响了最新的检查结果.

I need to execute this tool always, irrespective of whether a project is or is not up to date. Actually, even before MSBuild even determines whether the project is up-to-date, because the tool modifies some of the files included in the project, therefore affecting the up-to-date check result.

有正确的方法吗?

推荐答案

这是解决方案.在您的项目文件中定义此属性:

Here's the solution. Define this property in your project file:

<PropertyGroup>
    <DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
</PropertyGroup> 

然后每次都会执行 PreBuildStep,无论项目是否是最新的.

PreBuildStep will then execute every time, regardless of whether the project is or isn't up to date.

Visual Studio 似乎正在绕过 MSBuild 的正常最新检查,并使用某种速度更快的自定义检查,但有破坏自定义构建目标的副作用.

It seems that Visual Studio is bypassing normal up-to-date checks of MSBuild and using some sort of custom check that is faster, but has a side effect of breaking customized build targets.

这篇关于Visual Studio 添加始终运行的预生成事件(C# 项目)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆