如何在 Wpf 类库中包含一个 .dll

问题描述 投票:0回答:0

我正在准备一个Wpf类库。我在这个库中使用了一些 .dll 和 nuget 包。如何在我准备的 Wpf 类库输出中包含我使用的 .dll 和 nuget 包?

如果我不包含它,我必须在主项目中添加我在Wpf类库中使用的其他包和.dll。

我的目标是在单个 .dll 文件中组合和使用多个 .dll 和 nuget 包。

我得到了以下结果,但我还是无法包含 nuget 包。

如何包含类库引用的nuget包

    <Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>net472;net6.0-windows</TargetFrameworks>
    <UseWPF>true</UseWPF>
  </PropertyGroup>
  
  <PropertyGroup>
    <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
  </PropertyGroup>
  
  <ItemGroup>
    <PackageReference Include="Notification.Wpf" Version="7.0.0" />
  </ItemGroup>

</Project>

当我没有在主项目中安装 nuget 包时,我收到如下错误。当我安装 nuget 包时,问题消失了,但是用一个 .dll 文件处理它是不可能的吗?

The type 'NotificationManager' is defined in an assembly that is not referenced. You must add a reference to assembly 'Notification.Wpf, Version=7.0.0.0, Culture=neutral, PublicKeyToken=1acac493089262b5'.
.net wpf class-library
© www.soinside.com 2019 - 2024. All rights reserved.