【问题标题】:Compiling .NET project with different references and frameworks使用不同的引用和框架编译 .NET 项目
【发布时间】:2017-12-20 05:16:59
【问题描述】:

我正在构建一个 SDK dll,它需要支持具有不同引用的多个 .NET 框架。

例如,一个 SDK dll 用于 Azure Functions,它是 .Net 4.6.1,带有 Newtonsoft.Json 参考 9.0.0.1(硬编码到 Azure Functions 中)。另一个是带有 newtonsoft.json 10.0.3 的 .NET 4.5.1 框架。

使用框架和引用不同的一个 Visual Studio 解决方案从相同的 cs 代码文件构建 2 个 dll 的最佳方法是什么?

谢谢

【问题讨论】:

    标签: c# .net azure azure-functions


    【解决方案1】:

    您可以使用新的 .Net Standard 类库 https://docs.microsoft.com/en-us/dotnet/core/tutorials/library-with-visual-studio

    这样您就可以针对您的情况将最小库定位为 1.2 https://docs.microsoft.com/en-us/dotnet/standard/net-standard

    您可以从两个项目中引用此 dll。

    对于引用的程序集,您不需要指定依赖项的特定版本。这里有关于如何在这个答案上执行此操作的详细说明。

    How exactly does the "Specific Version" property of an assembly reference work in Visual Studio?

    【讨论】:

      【解决方案2】:

      在 Visual Studio 2015 或更高版本中使用 SharedProjects 可以定位多个框架和引用。

      http://www.c-sharpcorner.com/UploadFile/7ca517/shared-project-an-impressive-features-of-visual-studio-201/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-08-07
        • 2011-05-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-06-28
        相关资源
        最近更新 更多