VS2005 根据 .cpp 文件中的实现细节更改重建 .NET/CLI 项目
我的解决方案由几个本机 C++/CLI 包装器和托管库/程序集组成。包装器项目引用不同的本机 DLL 项目。每次我更改本机依赖项的 .cpp 文件中的实现细节时,所有 CLI/.NET 项目都会重新构建(不仅仅是链接,而是重新编译)。这也会发生在调试配置中(无全程序优化..)。这种行为有什么原因吗?由于解决方案相当大,重建需要大量时间,因此如果 VS 能够避免任何不必要的重建,那就太好了。
My solution consists of several native, C++/CLI wrapper and managed libraries/assemblies. The wrapper projects are referencing different native DLL-projects. Every time i change an implementation detail in a .cpp file of a native dependency, all CLI/.NET projects are rebuilt (not just linked, but recompiled). This also happens in the Debug configuration (no Whole-Programm Optimization..). Is there any reason for this behavior? Since the solution is quite big, rebuilding takes alot of time so it would be nice if VS would avoid any unneccessary rebuilds.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是预期的行为。 .NET 程序集“依赖”非托管 DLL,当 DLL 发生更改时,它们会检测到并重新构建。非托管 C++ 项目的编译单元是 .cpp 文件。 .NET 程序集的编译单元是整个程序集。没有办法只重新编译一个 .cs(或托管 c++)文件。
您可以通过使用 ::GetProcAddress() 获取指向非托管 DLL 中的操作的函数指针来解决此问题。然后,您可以删除 .NET 程序集对非托管 DLL 的 .lib 文件的依赖关系,并且每次 .lib 更改时它将不再重新编译。
This is expected behavior. The .NET assemblies "depend" on the unmanaged DLL and when the DLL changes they detect that and re-build. The compilation unit of an unmanaged C++ project is a .cpp file. The compilation unit of a .NET assembly is the whole assembly. There's no way to re-compile just one .cs (or managed c++) file.
You can get around this by using ::GetProcAddress() to get function pointers to the operations in the unmanaged DLL's. Then you can remove the .NET assembly's dependency on the .lib file of the unmanaged DLL's and it will no longer re-compile every time the .lib changes.