如何获得自定义构建规则,ExcludedFromBuild和依赖项一起工作? [英] How to get custom build rules, ExcludedFromBuild and dependencies working together?

查看:442
本文介绍了如何获得自定义构建规则,ExcludedFromBuild和依赖项一起工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用自定义生成规则时遇到了问题,到目前为止,我发现的每个示例似乎都遇到了相同的问题.

I have a problem with using custom build rules, that so far every example I have found seems to suffer from the same issue.

基本上,如果您为文件扩展名设置了自定义构建规则,并且将其中一些文件设置为不包含在构建中,那么我还没有找到在这种情况下可以正常工作的示例.如果我正确理解发生了什么事, 目标的输入包含输入文件的完整列表,包括将ExcludedFromBuild设置为true的文件,因此依赖系统会认为目标是脏的.然后在目标块内的命令内部存在一个条件,该条件仅执行该命令 如果ExcludedFromBuild!= true.尽管实际上并没有构建排除的文件,但这意味着它总是尝试构建它们.

Basically if you have a custom build rules setup for a file extension and have some of those files set to be excluded from build, I have yet to find an example that works correctly in this scenario. If I understand correctly what is happening is that the target's inputs contain the full list of input files, including those that have ExcludedFromBuild set to true so the dependency system thinks the target is dirty. Then there is a condition inside the command inside the target block that only executes the command if ExcludedFromBuild != true. Whilst the excluded files dont actually get built, it means it always tries to build them.

有趣的是,Visual Studio本身对此具有某种解决方法,如果我创建一个新的VS项目,则添加提供的masm构建自定义项,添加2个空的.asm文件(仅包含单词"END",因此它们组装),将其中之一标记为 不要构建,然后从命令行运行msbuild,它总是会显示一条消息以组装该文件.如果我改为尝试从Visual Studio进行构建,Visual Studio本身就会以某种方式知道该项目是最新的,因此甚至不调用msbuild. (这 我听说过提到的快速相关性检查).

Interestingly it looks like visual studio itself has some kind of workaround for this, if I create a new VS project, add the provided masm build customisation, add 2 empty .asm files (just containing the word "END" so they assemble), mark one of them as dont build and then run msbuild from the command line it always spits out a message for assembling that file. If I instead try to build it from visual studio, visual studio itself somehow knows that the project is up-to-date so doesn't even call msbuild. (The fast dependency check I have heard mentioned).

现在,我怀疑出于某种原因,这种快速依赖性检查在我自己的情况下没有发生,这就是为什么我什至开始研究这种情况,但似乎核心问题是所提供的错误不是正确的", msbuild没有办法处理 这种情况是正确"的. ?

Now I suspect that for some reason this fast dependency check isnt happening in my own case which is why I even started looking into this, but it seems like the core issue is that the provided masm aren't "correct", is there no way for msbuild to handle this scenario "correctly" ?

推荐答案

如果将ExcludedFromBuild设置为true,则不会构建排除的文件.

If we set ExcludedFromBuild as true, the excluded files will not be built.

我们知道Visual Studio使用MSBuild项目文件格式来存储有关托管项目的生成信息.通过Visual Studio添加和更改的项目设置反映在为每个项目生成的.* proj文件中. Visual Studio的使用 MSBuild的托管实例来构建托管项目.

We know Visual Studio uses the MSBuild project file format to store build information about managed projects. Project settings added and changed through Visual Studio are reflected in the .*proj file that is generated for each project. Visual Studio uses a hosted instance of MSBuild to build managed projects.

因此,我认为使用Visual Studio和Msbuild在构建上没有什么区别.

So I don't think there are some difference on building between using Visual Studio and Msbuild.

您想了解更多信息,请参阅:

What you want to learn more you can refer to:

http://msdn.microsoft.com/en-us/library/dd393574


这篇关于如何获得自定义构建规则,ExcludedFromBuild和依赖项一起工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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