首页 > 解决方案 > nuget 和直接引用 dll 的工作方式不同

问题描述

我是.Net 世界的新手,但仍在努力掌握它。我有一个 .Net core 2.1 项目,我试图直接在项目中引用Microsoft.Identity.Client.ExtensionsMicrosoft.Identity.Client库。我从 nuget 下载了 nupkg 文件并提取了包。我将lib\netcoreapp2.1中的库复制到我的项目目录中。我在 csproj 中添加了以下内容。

  <ItemGroup>
    <Reference Include="Microsoft.Identity.Client">
      <HintPath>Microsoft.Identity.Client.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Identity.Client.Extensions.Msal">
      <HintPath>Microsoft.Identity.Client.Extensions.Msal.dll</HintPath>
    </Reference>
  </ItemGroup>

但是,我没有添加 Microsoft.Identity.Client.Extensions 列出的未实现的依赖项。应用程序仍可编译,但未按预期运行。我查看了 .nuspec 文件,我注意到 nuget 提到了如下所示的依赖项,当项目重新使用 nuget 来引用库时,它运行良好。当我下载并手动引用 dll 时,情况并非如此。有什么方法可以将依赖项添加到我的 .csproj 文件中的现有 dll 中。问题是没有失败,应用程序没有按预期运行。

<dependencies>
      <group targetFramework=".NETCoreApp2.1">
        <dependency id="Microsoft.Identity.Client" version="4.15.0" exclude="Build,Analyzers" />
        <dependency id="System.Security.Cryptography.ProtectedData" version="4.5.0" exclude="Build,Analyzers" />
      </group>
</dependencies>

我确信nuget机制正在某处获取两个依赖项

标签: .net.net-corenugetmsalnuget-spec

解决方案


推荐阅读