Keeping projects in sync across multiple .NET versions

本小妞迷上赌 提交于 2019-11-29 15:03:29

What I do is:

  • 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)

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


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.

What I do with my cross platform projects is to have different slns, each for one platform.

The shared code lives in a common location and is added "as a link" into the correct csproj's. This csproj also contain any platform specific files. If a "common code" file needs to be conditional based on current platform you can choose to replace that with two platform-specific files or put a #ifdef in it (depends on how much of it is different).

Note that you can also add one solution to another inside Visual Studio. This "combined" solution can be used for automated builds for all platforms.

Example: https://github.com/ananthonline/graffiti

This works great for me, YMMV. Hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!