为什么我的项目在没有更改的情况下会构建?
我有许多 C# (Visual Studio 2008) 项目,其中一些项目正在更新程序集,即使没有发生任何更改(即使我选择“生成”而不是“重新生成”)。我的大多数项目都没有这样做,只是少数。
我还没有发现这些项目之间有任何区别,并且想知道是否有人知道什么可能会影响它。需要明确的是,我在生成之前没有进行任何代码更改,但当我在 Visual Studio 中运行“生成”命令时,仍在重新创建程序集。
很抱歉,我无法提供任何进一步的详细信息,但如果我可以检查其他任何内容可能会有所帮助,请告诉我。
有人可以帮忙吗?我已经为此烦恼了一段时间了。
谢谢, 艾伦
I've got many C# (Visual Studio 2008) projects and a few of them are updating the assembly even when there have been no changes (even when I choose Build and not Rebuild). Most of my projects don't do this, its just the odd few.
I have yet to find any difference between the projects and wondered if anyone had any ideas what could be influencing it. To be clear, I've not made any code changes before building but the assembly is still being recreated when I run the Build command within Visual Studio.
I'm sorry I can't provide any further details but please let me know if there is anything else that I can check that may shed some light.
Can anyone help? I've been tearing my hair out for a while on this.
Thanks,
Alan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
事实上,汉斯现已删除的答案为我指明了正确的方向。将 MSBuild 的详细程度提高到诊断告诉我,VS 认为一个项目总是过时,因为一个文件将“复制到输出目录”设置为“始终复制”。其他项目也随之跟进,因为它们依赖于该项目,并注意到新建的 DLL 比它们自己的输出文件之一更新。
将“复制到输出目录”更改为“如果较新则复制”解决了该问题。
Actually Hans' now-deleted answer pointed me to the right direction. Cranking up MSBuild's verbosity to diagnostic told me that VS considered a project always out of date because one file had "Copy to output directory" set to "Copy always". And the other projects followed from that because they depended on that project an noticed that the newly-built DLL was newer than one of their own output files.
Changing "Copy to output directory" to "Copy if newer" resolved that.
有一种叫做项目依赖性的东西。
当您的一个项目依赖于一个或多个其他项目并且您构建它时,您的项目所依赖的其他项目也将开始构建(如果需要)。此外,如果依赖项发生更改,则依赖于它们的项目将始终被重建。
您可以右键单击“解决方案”并选择“项目构建顺序”以打开一个窗口,其中解释了项目的构建顺序以及每个项目的依赖关系。
There is something called project dependencies.
When one of your project depends on one or more other projects and you build it the other projects that your projects depends on will also begin to be built (if needed). Additionally if the dependencies have changed then the projects dependent on them will always be rebuilt.
You can Right Click on Solution and select Project Build Order to bring up a window which explains the order in which projects are built and the dependencies for each project.
我没有深究这一问题,最终重建了其中一个项目。原来,这一切都源于这个一直在重建的项目。
我认为这与每次重建的嵌入式资源有关。
抱歉,我对此没有明确的答案。也感谢 RobV 提供的有用信息。
艾伦
I didn't get to the bottom of this one and ended up reconstructing one of the projects. It turned out that it was all stemming from this one project that was always rebuilding.
I think it had something to do with the embedded resources being rebuilt every time.
Sorry I don't have a definitive answer on this one. Thanks to RobV too for the useful information.
Alan