You probably get it
Failed to add link to 'libtidy'
because you have libtidy somewhere inside the lib folder. When you install the package, a link will be automatically added to this folder, and you cannot directly add a link to an unmanaged library.
If you have not already done so, you need to manually create your nuget package, and not execute it on a project or assembly. For this:
- Create a folder named nuget-libtidy
- Add libtidy.dll, TidyManaged.dll and everything you need to this folder
- Open
cmd and browse to the newly created folder. - Run
nuget spec to create the default manifest Package.nuspec (you will need to add nuget to your PATH environment variable Add the following xml to the nuspec file created immediately after the closing </metadata>
<files> <file src="libtidy.dll" target="content" /> <file src="TidyManaged.dll" target="lib" /> </files>
Adjust any other value you need.
You can do this, package and deploy the nuget package. You need to libtidy.dll copy to the output directory. This means that after installing the package you will have to go to the right-click on the \ libtidy.dll dependencies in visual studio, select the properties and set Copy to Output Directory to Copy Always .
If you do not want this to be done, you could make a few more settings in the nuget-libtidy folder and manifest file. Basically you need to create an Install.ps1 file that adds
<ItemGroup> <Content Include="libtidy.dll"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> </ItemGroup>
to the project file of the installed project.
Here is an example Install.ps1 that should do what you want:
param($installPath, $toolsPath, $package, $project) $file = $project.ProjectItems.Item("libtidy.dll"); If ($file -eq $null) { $project.ProjectItems.AddFromFile("libtidy.dll"); $file = $project.ProjectItems.Item("libtidy.dll"); } $file.Properties.Item("CopyToOutputDirectory").Value = [int]1;
After the PowerShell script completes, add another line to the manifest file:
<file src="Install.ps1" target="tools" />
Remember to run scripts on Windows 10 so that you set the execution policy. I would suggest running Set-ExecutionPolicy RemoteSigned . After starting in PowerShell, you will have to reboot the system.
At this point, you can pack and deploy.
EDIT
Typo is found in the Install.ps1 file. Line 3, $file1 = $project.ProjectItems.Item("libtidy.dll"); should be $file = $project.ProjectItems.Item("libtidy.dll";