实现一个.NET项目目标是包括3.5和4.0目标、项目、NET

2023-09-04 03:04:52 作者:半夏荼蘼

我们有一个项目(登录LIB)所使用的标准asp.net应用程序(4.0框架)以及通过SharePoint解决方案(3.5框架)。

We have a project (logging lib) that is used by standard asp.net apps (4.0 framework) and also by sharepoint solutions (3.5 framework).

有没有办法来定义,这样,当我们所建立的项目两个版本被内置两个目标?

Is there a way to define both targets so that when we build the project both versions gets built?

此外,如任何人实施这样的事情,并通过的NuGet分发?什么是对的NuGet发布两个版本的最佳方法?

Also, as anybody implemented something like this and distribute it via nuget? What's the best approach to publishing both versions on nuget?

感谢

推荐答案

答案是 < supportedRuntime> 的配置元素。这使您可以指定所有.NET运行时将您的应用程序能够支持和下运行。当然,在您的应用程序只能使用功能的.NET框架的所有您所选择的版本提供。

Answer is <supportedRuntime> config element. This allows you to specify all .NET runtimes your application can support and run under. Of course, in your application you can only use functionalities that all your chosen versions of .NET framework provide.

总之,你应该有这个在你的配置:

In short, you should have this in your config:

<configuration>
  <startup>
    <supportedRuntime version="v2.0.50727"/>
    <supportedRuntime version="v4.0"/>
  </startup>
</configuration>

这可能是必要的最初目标应用程序到.NET 3.5的&LT; supportedRuntime&GT; 允许上浮的版本,而不是往下走。

It might be necessary to originally target your application to .NET 3.5 as <supportedRuntime> allows to go up in versions rather than go down.