Reputation: 374
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. In my project i'm using a DLL (CoolProp.dll) which is a third-party dll.
When running the program it needs to have the dll in:
..\bin\Release\CoolProp.dll
In the Solution Explorer (VS) I have set the CoolProp.dll to:
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)
<file src="bin\Release\CoolProp.dll" target="lib\net461" />
When installing the Nuget I get the followering error:
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. It should just copy it and nothing else.
What am I doing wrong? or is there something I have misunderstood?
Upvotes: 4
Views: 688
Reputation: 374
I finally got it to work!
My mistake was to put the dll in to the "lib\net461" folder. 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:
<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.
Upvotes: 3