MSBuild建设太多了 [英] MSBuild Building Too Much

查看:70
本文介绍了MSBuild建设太多了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们遇到了MSBuild的问题,我试图了解发生了什么事情。


我们使用Visual Studio 2015并拥有一个大型解决方案(太大了,91个项目)大部分混合了C ++和C#。


如果我在IDE中重建所有内容,大约需要7分钟。如果我然后执行另一个构建(没有更改),它会在不到5秒的时间内返回,并且不会重建任何内容。


这很好,但我们一起构建了许多解决方案并拥有一个应用程序驱动MSBuild以正确的顺序构建解决方案。 MSBuild命令行只是


C:\Program Files(x86)\ MSBuild\14.0\bin\msbuild.exe $(SolutionFileName)/ t:BUILD / verbosity :minimal / m / nr:false / p:Configuration = DEBUG / p:Platform =" x86" /p:VisualStudioVersion=14.0



然而,在完全构建的解决方案上,同样的线路花了近3分钟开始构建一个解决方案中的各种项目(所有项目都正确识别无关,但仍然运行所有的前后构建步骤)


我已尝试将日志记录设置为Diagnostic和我可以看到消息说< mysolution> .sln正在构建< myproject> .vcproj,但它并没有告诉我为什么它会启动那些没有改变的项目构建。


<我已经找到了常见的丢失文件,我检查了项目依赖项,并且所有文件似乎都是有效的。我不知道接下来要看什么,这对于我们所有使用MSBuild实用程序的开发人员来说都是一个令人沮丧的浪费时间。



关于我如何尝试调试此问题的任何想法?


解决方案

Jeremy Young,


感谢您在此发帖。


>>> 有任何关于我的想法可以尝试调试此问题吗?


这是MSBuild的默认行为。据我所知,在Visual Studio中,有两层最新的检查。 MSBuild本身有一个每个目标检查,目标应该是指定输入和输出。并且目标无法禁用,
以及MSBuild命令行也支持。因此,当您再次构建项目而没有任何修改时,我们可以看到大多数目标都会跳过。 


但是,Visual中最新的构建的记录输出Studio看起来非常类似于没有的构建。这个想法是增量性是Visual Studio中的优化。所以Visual Studio会在不到5秒的时间内回来并且不会
重建任何内容,只会给出消息"==========构建:0成功,0失败,
4最新,0跳过==========

"


在Visual Studio中,有"快速最新检查"。当没有任何修改时,
完全避免调用MSBuild 。这种"快速检查"由Visual Studio支持,因此当您使用MSBuild构建解决方案时,不会调用此快速,MSBuild将启动解决方案中各种
项目的构建,但跳过项目中的大部分目标。 


因此,为解决方案中的各种项目开始构建 不可避免,  幸运的是,这不会花费太多时间。


希望这会有所帮助。


We are having an issue with MSBuild and I've hit a brick wall trying to understand what is going on.

We use Visual Studio 2015 and have a large Solution (too large, 91 projects) mixed C++ and C# for the most part.

If I rebuild everything in the IDE, it takes about 7 minutes. If I then perform another build (no changes) it comes back in less than 5 seconds and doesn't rebuild anything.

This is great, but we build many solutions together and have an application that drives MSBuild to build the solutions in the correct order. The MSBuild command line is simply

C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe $(SolutionFileName) /t:BUILD /verbosity:minimal /m /nr:false /p:Configuration=DEBUG /p:Platform="x86" /p:VisualStudioVersion=14.0

However, this same line, on a fully built up solution, spends almost 3 minutes kicking off builds for a variety of projects in the solution (all of which correctly identify there is nothing to do, but still run all their pre and post-build steps)

I have tried setting the logging to Diagnostic and I can see the messages saying <mysolution>.sln is building <myproject>.vcproj, but it doesn't tell me why it's kicking off builds of projects that haven't changed.

I've looked for the usual missing files, I've checked project dependencies and all appear to be valid. I don't know what to look at next and this is a frustrating waste of time for all our developers using the MSBuild utility.

Has anybody any ideas on how I can try to debug this issue?

解决方案

Hi Jeremy Young,

Thanks for posting here.

>>>Has anybody any ideas on how I can try to debug this issue?

This is the default behavior of MSBuild. As aware as I know, in Visual Studio, there are double layers of up-to-date checks. MSBuild itself has a check per-target, the target should be specified Inputs and Outputs. And the target can't be disabled, and which also supported by MSBuild command line. So we could see most of target would be skip when you build the project again without any modification. 

However, the logged output of a build that is up-to-date in Visual Studio can look very similar to a build that wasn't. This idea being that incrementality is an optimization in Visual Studio. So Visual Studio comes back in less than 5 seconds and doesn't rebuild anything, only give the message "========== Build: 0 succeeded, 0 failed, 4 up-to-date, 0 skipped ==========
"

Inside Visual Studio, there are "fast up-to-date checks" that avoid invoking MSBuild at all when nothing has been modified. This "fast check" supports by Visual Studio, so when you build your solution with MSBuild, this fast will not invoked, MSBuild will kick off builds for a variety of projects in the solution, but skip most of target in the project. 

So, kicking off builds for a variety of projects in the solution isunavoidable, fortunately, this would not take too much time.

Hope this helps.


这篇关于MSBuild建设太多了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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