在 VS 构建时交换引用
我有一个在 .NET 和 .NET CF 上运行的项目。但它使用了第三方库 这不会在两者上运行。所以我最终会在每次项目构建时更改参考。
项目 A - 引用第 3 方 dll。
项目 B - 引用 A 并运行 .NET CF
项目 C - 引用 A 并运行 .NET
有没有办法自动化它?
以下是该第三方库的链接:http://dotnetzip.codeplex.com/Wikipage
I have a project that runs on both .NET and .NET CF. But it uses a 3rd party library
that will not run on both. So I end up changing the reference every time the project gets built.
Project A - References the 3rd party dll.
Project B - References A and runs .NET CF
Project C - References A and runs .NET
Is there a way to automate it?
Here is a link to that 3rd party library: http://dotnetzip.codeplex.com/Wikipage
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在解决方案中设置两种构建配置 - 一种用于 .Net,一种用于 .Net CF - 并使用条件引用来切换引用的库版本。
为
.Net
和.Net CF
设置两个新的构建配置(与调试和发布配置相同,即构建 -> 配置管理器)。添加 .Net 和 .Net CF 第 3 方 dll 作为对项目 A 的引用。然后,您需要手动编辑项目 A 的项目文件 - 请参阅我的 关于如何执行此操作的先前答案。确保将项目 B 设置为不在.Net
构建配置中构建,并将项目 C 设置为不在.Net CF
构建配置中构建。这使您能够基于当前选择的构建配置构建
.Net
输出或.Net CF
输出,所有这些都在一个解决方案中,并且全部使用相同的项目。You can set up two build configurations in your solution - one for .Net and one for .Net CF - and use conditional references to switch which version of the library is referenced.
Set up two new build configurations for
.Net
and.Net CF
(the same as you would for debug and release configurations ie. Build -> Configuration Manager). Add both the .Net and the .Net CF 3rd party dlls as references to project A. You will then need to hand-edit the project file for project A - see my previous answer for how to do this. Make sure you set project B to not build in the.Net
build configuration and project C to not build in the.Net CF
build configuration.This enables you to build either a
.Net
output or a.Net CF
output based on the currently selected build configuration, all within one solution, all using the same projects.您可以制定单独的解决方案并为每个解决方案适当地设置构建配置。不过,从那时起,您将必须手动维护这两个解决方案。
You could make separate solutions and setup build configurations appropriately for each. You would have to maintain both solutions manually, though, from then on.