构建.NET 4和.NET 4.5整个解决方案和文件复制到特定的文件夹文件夹、解决方案、文件、NET

2023-09-05 03:23:26 作者:匿名的关系

短说明的当前形势:我们两个解决方案与一帮将军'助手'库。我们需要所有这些库.NET 4和.NET 4.5,因为我们的一些依赖这些库项目在未被感动系统正在运行,这意味着我们不能把.NET 4.5的系统。

Short description of the current situation: We've two solutions with a bunch of general 'helper' libraries. We need all those libraries for .NET 4 and .NET 4.5 since some of our projects that depend on those libraries are running on systems that are not to be touched, meaning we can't put .NET 4.5 on those systems.

我们已经工作构建服务器(TFS2012)的建立,一旦每晚所有解决方案。目前,我们获得由错误,因为无论是.NET淹没4个项目或.NET 4.5的项目不能建,取决于当前的状态签入的.csproj的文件。

We've a working build server (TFS2012) that builds all solutions once per night. Currently we get swamped by errors since either the .NET 4 projects or the .NET 4.5 projects can't be build, depending on the current state of the checked-in .csproj files.

我要什么/ 什么是完美:当一个人(不管它是在buildserver或一个Visual Studio)编译'帮手'的解决方案,一个.NET 4和.NET 4.5版本这些文件被编译。在.NET 4中的文件复制到 C:\ DLL \ A 和.NET 4.5的版本将被复制到 C:\ DLL \ b

What I want/what would be perfect: When someone (regardless of it it's the buildserver or a Visual Studio) compiles the 'helper' solutions, a .NET 4 and a .NET 4.5 version of those files is compiled. The .NET 4 files are copied to C:\dll\a and the .NET 4.5 version is copied to C:\dll\b.

我偶然发现:http://shazwazza.com/post/multi-targeting-a-single-net-project-to-build-for-different-framework-versions/但鉴于.csproj的文件,我真的不想这样做,每个.csproj的文件量。

What I stumbled upon: http://shazwazza.com/post/multi-targeting-a-single-net-project-to-build-for-different-framework-versions/ but given the amount of .csproj files I really do not want to do that for each .csproj file.

我的问题存在:

有没有办法来编译.NET 4和.NET 4.5和复制编译库,以特定的文件夹整个解决方案?

如果是的话,那我怎么办呢?

如果不是,是否有这样做的另一种方式,从根本上导致了同样的结果(.NET 4的相同的.NET 4.5库 code在两个不同的位置,这样它们可以通过被引用 其他项目)?

If not, is there an alternative way of doing this, essentially leading to the same result (.NET 4 and .NET 4.5 libraries of the same code in two different locations so that they can be referenced by other projects)?

推荐答案

从本质上讲,一个的csproj是一个构建的目标;而有些事情是可以改变的参数上构建,基础平台等都是棘手,这是一个更好的主意,只是保持每构建目标不同的csproj。

Essentially, a csproj is a build target; while some things can be changed as parameters on a build, the fundamental platform etc is trickier, and it is a much better idea to simply maintain a different csproj per build target.

您正确(评论)观察到,这意味着你将需要保持在两个分开的参考 - 这是不可避免的,因为某些平台上使用完全不同的dll文件来获得同样的事情(CF,WinRT的,等等)

You correctly (comments) observe that this means you will need to maintain references in both separately - that is unavoidable, since some platforms use completely different dlls to get the same things (cf, winrt, etc).

不过,是的没有的必然,你需要单独维护文件的情况下,这里是从便携式类库构建protobuf网:

However, is not necessarily the case that you need to maintain the files separately; here's a line from the portable class library build for protobuf-net:

<Compile Include="..\protobuf-net\**\*.cs" />

这意味着: .. \ protobuf网下编译所有的.cs文件(递归)。你可能preFER分别维持在较小的项目文件列表 - 例如,这里的短小精悍:

Which means: compile all .cs files (recursively) under ..\protobuf-net. You might prefer to maintain the file list separately in smaller projects - for example, here's "dapper":

小背光模组箭头指示文件的链接,所以你可以看到:在主的code是小巧玲珑NET40,以小巧玲珑NET35和小巧玲珑NET45使用相同的文件(衣冠楚楚NET45还增加了一个额外的文件)。

The little blus arrows indicate file links, so as you can see: the primary code is in "Dapper NET40", with "Dapper NET35" and "Dapper NET45" using the same files ("Dapper NET45" also adds an additional file).

和强调为什么提到需要单独维护,这里的StackExchange.Redis对.NET 4.5:

And to emphasize why the references need to be maintained separately, here's "StackExchange.Redis" for .NET 4.5:

(非常干净) - 这里的StackExchange.Redis对.NET 4.0:

(nice and clean) - and here's "StackExchange.Redis" for .NET 4.0:

额外的引用从 Microsoft.Bcl ,用来获取完整的工作 API(和其他依赖)在.NET 4.0中(它内置在.NET 4.5):

The extra references are from Microsoft.Bcl, used to get the full Task API (and other dependencies) in .NET 4.0 (it is inbuilt in .NET 4.5):

<packages>
  <package id="Microsoft.Bcl" version="1.1.9" targetFramework="net40" />
  <package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" />
  <package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" />
</packages>