[英]NuGet: Copying .DLL file without creating a reference?
I am working on my first open source project and now I want to create a NuGet from it so it is easy to use.我正在开发我的第一个开源项目,现在我想从中创建一个 NuGet ,以便它易于使用。 In my project i'm using a DLL (CoolProp.dll) which is a third-party dll.
在我的项目中,我使用的是第三方 DLL 的 DLL (CoolProp.dll)。
When running the program it needs to have the dll in:运行程序时,它需要将 dll 放在:
..\bin\Release\CoolProp.dll
In the Solution Explorer (VS) I have set the CoolProp.dll to:在解决方案资源管理器 (VS) 中,我将 CoolProp.dll 设置为:
Build Action: None
Copy to Output Directory: Copy always
All this works as it should when just running the code.所有这些都在运行代码时正常工作。
In the .nuspec file I have added: (for it to copy the dll file)在我添加的 .nuspec 文件中:(为了它复制 dll 文件)
<file src="bin\Release\CoolProp.dll" target="lib\net461" />
When installing the Nuget I get the followering error:安装 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.
I am guessing it is trying to add a reference to the dll file, which its shouldn't do.我猜它正在尝试添加对 dll 文件的引用,这是它不应该做的。 It should just copy it and nothing else.
它应该只是复制它而不是其他任何东西。
What am I doing wrong?我究竟做错了什么? or is there something I have misunderstood?
还是我误解了什么?
I finally got it to work!我终于让它工作了!
My mistake was to put the dll in to the "lib\\net461" folder.我的错误是将 dll 放入“lib\\net461”文件夹中。 As I understand it, putting it into that folder tell the system to make a reference to it.
据我了解,将其放入该文件夹会告诉系统对其进行引用。
Instead I did this:相反,我这样做了:
<file src="..\CoolProp.dll" target="build\" />
<file src="..\SharpFluids.targets" target="build\" />
Created a file name "SharpFluids.targets" and put this into it:创建一个文件名“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>
So now it just copies the dll file into output-folder without trying to create a reference to it.所以现在它只是将 dll 文件复制到输出文件夹中,而不尝试创建对它的引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.