[英]NuGet: Copying .DLL file without creating a reference?
我正在开发我的第一个开源项目,现在我想从中创建一个 NuGet ,以便它易于使用。 在我的项目中,我使用的是第三方 DLL 的 DLL (CoolProp.dll)。
运行程序时,它需要将 dll 放在:
..\bin\Release\CoolProp.dll
在解决方案资源管理器 (VS) 中,我将 CoolProp.dll 设置为:
Build Action: None
Copy to Output Directory: Copy always
所有这些都在运行代码时正常工作。
在我添加的 .nuspec 文件中:(为了它复制 dll 文件)
<file src="bin\Release\CoolProp.dll" target="lib\net461" />
安装 Nuget 时出现以下错误:
Failed to add reference to 'CoolProp'
Please make sure that the file is accessible, and that it is a valid assembly or COM component.
我猜它正在尝试添加对 dll 文件的引用,这是它不应该做的。 它应该只是复制它而不是其他任何东西。
我究竟做错了什么? 还是我误解了什么?
我终于让它工作了!
我的错误是将 dll 放入“lib\\net461”文件夹中。 据我了解,将其放入该文件夹会告诉系统对其进行引用。
相反,我这样做了:
<file src="..\CoolProp.dll" target="build\" />
<file src="..\SharpFluids.targets" target="build\" />
创建一个文件名“SharpFluids.targets”并将其放入其中:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<NativeLibs Include="$(MSBuildThisFileDirectory)**\*.dll" />
<None Include="@(NativeLibs)">
<Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
所以现在它只是将 dll 文件复制到输出文件夹中,而不尝试创建对它的引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.