如何为不同的框架构建C#解决方案?

发布于 2024-10-09 11:34:00 字数 140 浏览 10 评论 0原文

我必须做出哪些选择来为不同的目标框架构建 VS2008 解决方案,只需“一键点击”?我需要构建 .net-2.0 和 netcf-2.0。 问题是我需要为 netcf-2.0 引用不同的库。

我尝试用 nant 做到这一点,但这似乎是一项复杂的任务。

Which choices I have to build a VS2008 solution for different target frameworks, with only "one click"? I need to build for .net-2.0 and netcf-2.0.
The problem is that I need referencing different libraries for netcf-2.0.

I tried to do this with nant, but that seems to be a complicated task.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

只等公子 2024-10-16 11:34:00

我不使用不同的构建配置。

当我这样做时,我为 CF 版本创建了一个单独的项目。在 CF 版本中,编译属性组使用所有原始源文件的链接。

CF 和全框架库由独立项目覆盖。每个项目都可以有一组独立的构建后或预构建任务、一组独立的引用、一组不同的 #define 符号等。

就我而言,并非所有代码都在库的完整框架版本中使用被编译为 CF 版本。使用部分类,我将仅用于完整框架版本的代码分解为单独的模块,并且我不会将这些源文件的链接添加到 CF 项目中。

您可以通过使用 #if 语句并在 CF 项目的 .csproj 文件中定义 CF 符号(或类似符号)来执行等效操作。

I don't use different build configurations.

When I did this I created a separate project for the CF version. Inside the CF version the Compile property group uses links to all the original source files.

The CF and full-framework libraries are covered by independent projects. Each project can have an independent set of post-build or pre-build tasks, an independent set of references, a distinct set of #defined symbols, etc.

In my case, not all code used in the full-framework version of the library gets compiled for the CF version. Using partial classes, I factor the code used only for the full-framework version into separate modules, and I don't add links for those source files into the CF project.

You could do the equivalent by using #if statements, and defining a CF symbol (or similar) in the .csproj file for the CF project.

风为裳 2024-10-16 11:34:00

将不同的项目保留在一个解决方案中,并使用针对不同框架版本的相同文件列表。

或者按框架版本对项目/解决方案进行分组。

Keep different projects in a single solution with the same file list targeted to different framework versions.

Or group projects/solution by framework version.

心在旅行 2024-10-16 11:34:00

您是否尝试过为每个目标框架创建单独的构建配置?

例如,复制您的调试配置并修改为您的匹配条件,并将其命名为 FrameWork_2_0 等等...

现在您只需为每个配置在解决方案上调用一次 MSBuild/NAnt 任务即可

Have you tried creating separate build configurations for each of the target frameworks?

For example, copy your Debug config and modify to your matching conditions and name it as FrameWork_2_0 and so on...

And now you can simply call an MSBuild/NAnt task on your solution once for each configuration

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文