[英]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.