在多个版本的.NET项目保持同步 [英] Keeping projects in sync across multiple .NET versions

查看:185
本文介绍了在多个版本的.NET项目保持同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建我的应用程序中的一些核心库,将在这两个.NET 3.5和.NET 4.0可用。我很高兴创造了多个项目,创建必需的定义和使用 #IFDEF 来控制哪些代码使之成为其输出组件。

I need to create some core libraries within my application which will be available in both .NET 3.5 and .NET 4.0. I'm happy creating multiple projects, creating the required defines and using #ifdef to control which code make it into which output assembly.

不过,我想知道的是,如果有保存这些项目同步的一种方式?当我在XNA开发,我有一个Windows版本和Windows Phone的版本 - 和XNA注入一个属性,称为项目文件 XnaCrossPlatformGroupID 。它与该作用是使Visual Studio中,自动将确保当将文件添加到项目时,它被添加到相应的项目。因此,举例来说,如果我一个名为 Foo.cs 文件添加到我的项目的Windows副本,那么相同的文件被添加到项目的Windows Phone的副本。

However, what I would like to know is if there is a way of keeping those projects in sync? When I am developing under XNA, I have a Windows build and a Windows Phone build - and XNA injects a property into the project file called XnaCrossPlatformGroupID. What it does with that is enable Visual Studio to automagically make sure that when a file is added to a project, it is added to the corresponding project. So, for example, if I add a file called Foo.cs to the Windows copy of my project, then that same file is added to the Windows Phone copy of the project.

是否有复制的那种行为的一个正常的一套Visual Studio中的项目什么办法?我宁愿不使用建配置,我想能够编译所有目标平台在单一步骤,而不诉诸工具以外的IDE(像TeamCity的,例如)。还是有另一种允许一个项目,针对多个目标构建,而不尖刻用20种不同的生成配置解决的方法?

Is there any way of replicating that sort of behaviour for a normal set of projects within Visual Studio? I would prefer not to use build configurations, as I would like to be able to compile all targeted platforms in a single step, without resorting to tools outside of the IDE (something like TeamCity, for instance). Or is there another method that allows a project to be built against multiple targets without peppering the solution with 20 different build configurations?

推荐答案

我要做的就是:


  • 有一个正规的csproj,我用我的大多数开发,加入文件等 - 但是记住确实的所有文件都中的

  • 对于其他的csproj,使用这样的:

  • have one "regular" csproj that I use for most of my dev, adding files etc - but remembering that really all files are "in"
  • for the other csproj, use something like:

<ItemGroup>
  <Compile Include="..\Foo\**\*.cs" />
</ItemGroup>


(即基本等同于增加为纽带,而无需将在每个文件的基础上完成的)

(that is basically the same as "add as link", but without needing to be done on a per-file basis)

这是一个递归包括所有*的.cs文件,所以一切都在无文件维护必要的。

This is a recursive include of all *.cs files, so everything is in. No file maintenance needed.

如果你试图指定多个框架(而不是多个版本的),那么另一种选择可能是:使用便携式类库 。这是一个单一的项目,在多个框架,的作品,但仅限于从你的目标平台的特性严格交集。在VS2010这是一个附加的功能;它在默认情况VS 11包括在内。

If you were trying to target multiple frameworks (rather than multiple versions), then another option might be: use a Portable Class Library. This is a single project that works on multiple frameworks, but is limited to the strict intersection of features from the platforms you target. In VS2010 this is an add-in feature; it is included by default in VS 11.

这篇关于在多个版本的.NET项目保持同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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