简体   繁体   English

减少.net核心/标准中的程序包依赖性

[英]Reducing Package Dependencies in .net core/standard

I'm trying to upgrade some libraries I've built in VS2015/.net core to VS2017. 我正在尝试将在VS2015 / .net核心中构建的一些库升级到VS2017。 While the project.json > *.csproj conversion went fairly well, I'm having troubles trying to make my library(ies) not depend on the full framework but only on the packages I really need. 虽然project.json> * .csproj转换进行得相当顺利,但是我在尝试使我的库不依赖于完整框架而仅依赖于我真正需要的包时遇到了麻烦。

What I previously did was documented at https://docs.microsoft.com/en-us/dotnet/articles/core/deploying/reducing-dependencies 我以前所做的工作已记录在https://docs.microsoft.com/zh-cn/dotnet/articles/core/deploying/reducing-dependencies

That was working fine. 很好。 After the upgrade, my "Dependencies" has the SDK nuget installed and it can't be removed. 升级后,我的“依赖项”已安装SDK nuget,无法将其删除。

Project.csproj contains the following: Project.csproj包含以下内容:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <AssemblyTitle>DDS.Core.Commons.Annotations</AssemblyTitle>
        <VersionPrefix>17.03.08.1526</VersionPrefix>
        <TargetFrameworks>netstandard1.6;net46</TargetFrameworks>
        <AssemblyName>DDS.Core.Commons.Annotations</AssemblyName>
        <PackageId>$(AssemblyName)</PackageId>
        <RootNamespace>DDS.Core.Commons.Annotations</RootNamespace>
    </PropertyGroup>

    <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
        <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
        <DebugType>full</DebugType>
    </PropertyGroup>

    <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
        <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
        <PublicSign>true</PublicSign>
        <DebugType>portable</DebugType>
        <GenerateDocumentationFile>true</GenerateDocumentationFile>
        <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
    </PropertyGroup>
</Project>

I omitted some properties (description, author, etc) for brevity. 为了简洁起见,我省略了一些属性(描述,作者等)。

Do anyone has any idea on how the above can be accomplished now? 有人对现在如何实现上述目标有任何想法吗? Thanks in advance. 提前致谢。

You can set 你可以设定

<PropertyGroup>
    <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
</PropertyGroup>

In your .csproj. 在您的.csproj中。 This tells the SDK to not reference NETStandard.Library or Microsoft.NETCore.App implicitly. 这告诉SDK不要隐式引用NETStandard.Library或Microsoft.NETCore.App。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM