【发布时间】:2021-05-29 01:25:51
【问题描述】:
问题:顶级项目引用 MyLibrary nuget,它引用了几个 vendor.dll 文件。当 MyLibrary nuget 包添加到顶级项目时,顶级项目应该能够引用 Vendor.dll 文件,但它们不是。
当我运行顶级项目时,我收到此错误:
FileNotFoundException:无法加载文件或程序集“Vendor.A,Culture=neutral,PublicKeyToken=b88d1754d700e49a”。系统找不到指定的文件。
供应商 .dll 文件不会复制到 bin 文件夹。
我希望找到不需要我创建 .nuspec 文件的解决方案。
生成的 MyLibrary nuget 包的结构(用 Nuget 包浏览器观察):
lib
net5.0-windows
Vendor.a.dll
Vendor.b.dll
net5.0-windows7.0
MyLibrary.dll
我不明白net5.0-windows7.0 来自哪里。它不存在于下面引用的 TFM 列表中。另外,如果由于某种原因需要net5.0-windows7.0,为什么那里存在MyLibrary.dll 而不是它所依赖的.dll?
从 Visual Studio 2019 中查看包,如下所示(未出现供应商 dll):
Packages
MyLibrary
Compile Time Assemblies
MyLibrary.dll
MyLibrary.csproj:
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<PropertyGroup>
<AssemblyVersion>1.0.0.1</AssemblyVersion>
<FileVersion>1.0.0.1</FileVersion>
<Version>1.0.0.3</Version>
</PropertyGroup>
<ItemGroup>
<Content Include="$(OutputPath)\Vendor.*.dll">
<Pack>true</Pack>
<PackagePath>lib\$(TargetFramework)</PackagePath>
</Content>
</ItemGroup>
<ItemGroup>
<Reference Include="Vendor.a">
<HintPath>VendorLib\Vendor.a.dll</HintPath>
</Reference>
<Reference Include="Vendor.b">
<HintPath>VendorLib\Vendor.b.dll</HintPath>
</Reference>
</ItemGroup>
TopLevel.csproj
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MyLibrary" Version="1.0.0.3" />
</ItemGroup>
Similar question requiring nuspec
【问题讨论】:
标签: visual-studio msbuild nuget nuget-package .net-5