Visual Studio 重建未修改的项目 [英] Visual Studio Rebuilds unmodified projects

查看:30
本文介绍了Visual Studio 重建未修改的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,正如标题所说,我现在有一个 VS2010 解决方案,其中包含大约 50 个项目.如果我对没有任何引用的顶级"项目进行更改,那么 VS 仍会重建所有 50 个项目.我正在运行 Visual Studio 2010 Ultimate,没有任何附加组件.我正在使用 ILMerge 将所有项目合并到一个文件中.

So, as the title reads, I have a VS2010 solution with ~50 projects in it right now. If I make a change to a "top level" project that nothing references then VS still rebuilds all 50 projects. I'm running Visual Studio 2010 Ultimate without any add-ons. I am using ILMerge to consolidate all of the projects into a single file.

我已经通过检查较低级别 dll 的时间戳验证了这一点,并发现即使它们的代码没有被触及,它们确实被重建了.

I have verified this by checking the time stamps of the lower level dlls and see that they are indeed rebuilt even though their code wasn't touched.

我已阅读以下所有回复和评论:

I've read all responses and comments for:

Visual Studio 2008 不断重建

Visual Studio 不断构建一切

我的解决方案中出现奇怪的 VS2010 构建故障

在 Visual Studio 中重建 C# 项目的原因

但他们中的大多数只是提供有关卸载项目以加快构建时间的建议,但没有具体的修复方法.我试图弄清楚为什么 VS 认为这些依赖项目不需要并修复它时需要重建.

But most of them just offer suggestions on unloading projects to speed up build times but nothing concrete as to a fix. I'm trying to figure out why VS thinks these dependent projects need to be rebuilt when they don't and fix it.

我已打开工具 > 选项 > 项目和解决方案 > 构建和运行 > 仅在运行时构建启动项目和依赖项"但没有任何效果.

I've turned on 'Tools > Options > Projects and Solutions > Build and Run > Only build startup projects and dependencies on run' but with no effect.

此外,如果我只是重建一个只有 8 个(in)直接依赖项的中级"项目,那么它仍然会构建所有 8 个项目,即使没有调用 ILMerge 并且没有任何依赖项目被修改.

Also, if I just rebuild a "mid-level" project that only has 8 (in)direct dependencies then it still builds all 8 projects even though ILMerge isn't invoked and none of the dependent projects have been modified.

感谢大家提供的任何见解.

Thank you everyone for any insight you may be able to provide.

已添加

为了测试一些建议,我从头开始创建了一个新的 WinForms 项目.然后我在该解决方案中创建了两个新项目.我将两个最低级别"项目中的所有代码和资源(不是项目文件)复制到两个全新项目中(我通过将文件和文件夹从资源管理器拖放到 Visual Studio 中的项目中来做到这一点).

To test some of the suggestions I created a new WinForms project from scratch. I then created two new projects inside that solution. I copied all of the code and resources (not project file) from my two 'lowest level' projects into the two brand new projects (I did this by dropping the files and folders from Explorer onto the project in Visual Studio).

最底层的项目,我们称之为B,没有引用任何其他项目.下一个项目 A 仅引用了 B.因此,一旦我将所需的 .NET 和外部程序集引用添加到项目中,就会构建解决方案.

The lowest project, let's call it B, did not reference any other project. The next project, A, referenced B only. So once I added the required .NET and external assembly references to the projects then the solution would build.

然后我获得了我的新 WinForm 项目参考 A 并进行了完整构建.所以引用链是:

I then had my new WinForm project reference A and did a full build. So the ref chain is:

WinForm -> A -> B

然后我修改了WinForm并进行了标准构建 (F6).和以前一样,Visual Studio 重建了所有三个项目.

I then modified WinForm only and did a standard build (F6). As before, Visual Studio rebuilt all three projects.

在对项目 B 中的源文件进行一些系统的删除后,我发现如果我删除了我的 Resources.Designer.csResources.resx(并注释掉使用这些资源的 .Properties.Resources 对象的代码)然后 WinForm 的修改将不再重建整个解决方案,只会重建WinForm.

After some systematic eleminiation of source files in project B I found that if I removed my Resources.Designer.cs and Resources.resx (and commented out the code that made use of the .Properties.Resources object of those resources) then a modification of WinForm would no longer rebuild the entire solution and would only rebuild WinForm.

Resources.resxResources.Designer.cs 添加回项目 B(但将引用的代码注释掉,以便没有正在利用资源)将重新引入完整的构建行为.

Adding the Resources.resx and Resources.Designer.cs back to project B (but leaving the referenced code commented out so that nothing was making use of the resources) would re-introduce the full build behavior.

为了查看我的资源文件是否已损坏,我再次删除了它们,然后创建了一个新的(通过项目属性 -> 资源)并重新添加了与以前相同的资源,即单个 Excel 文件.使用此设置,仍会进行完全重建.

To see if perhaps my resource files were corrupted, I deleted them again and then created a new one (via Project Properties -> Resources) and re-added the same resource as before, which was a single Excel file. With this setup the full rebuild would still occur.

然后我删除了单个资源,但将资源文件留在了项目 B 中.即使没有添加任何资源,但资源文件仍在项目中,也会发生完全(不需要的)重建.

I then removed the single resource, but left the resource file in project B. Even with no resources added, but the resource file still in the project, the full (unneeded) rebuild would occur.

似乎只是将资源文件添加到 (.NET 3.5) 项目将导致 Visual Studio 2010 始终重建该项目.这是错误还是预期/预期行为?

It appears that just having a resource file added to a (.NET 3.5) project will cause Visual Studio 2010 to always rebuild that project. Is this a bug or intended/expected behavior?

再次感谢大家!

推荐答案

打开工具 - 选项,选择项目和解决方案 - 在树中构建和运行,然后将MSBuild 项目构建输出详细程度"设置为诊断.这将输出构建项目的原因,即

Open Tools - Options, select Projects and Solutions - Build and Run in tree, then set "MSBuild project build output verbosity" to Diagnostic. This will output the reason for building a project, i.e.

项目ReferencedProject"不是最新的.项目项目'c:some.xml' 的 'Copy to Output Directory' 属性设置为 'Copy总是'.

Project 'ReferencedProject' is not up to date. Project item 'c:some.xml' has 'Copy to Output Directory' attribute set to 'Copy always'.

项目MyProject"不是最新的.输入文件'c:ReferencedProject.dll' 在输出文件后被修改'c:MyProject.pdb'.

Project 'MyProject' is not up to date. Input file 'c:ReferencedProject.dll' is modified after output file 'c:MyProject.pdb'.

在这种情况下,修复方法是仅在较新时才复制 some.xml.

In this case the fix is to copy some.xml only if newer.

构建前和构建后事件也可以触发构建.

Pre and post build events can trigger build as well.

这篇关于Visual Studio 重建未修改的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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