I have created a NuGet package libtidy
which is pushed to a Team Services feed.
When I try installing via the NuGet console I get the error
Failed to add reference to 'libtidy'
I have read this Stack Overflow post where the OP has a similar problem but I have been unable to resolve the issue - I've tried:
- Deleting all the folders inside of the packages folder and updating
- Executing
regsvr32 "C:\Program Files (x86)\Common Files\microsoft shared\MSEnv\VsLangproj.olb"
from an elevated command prompt - Doing
Uninstall-Package libtidy -force
from the package manager console (this doesn't work as the package isn't installed git clean -dfx
- clearing nuget cache
- manually removing the libtidy directory in the .nuget directory
EDIT
Having done a little research, could this be to do with the fact that libtidy.dll is not managed code? Infact it is ANSI-C. In our application we are using TidyManaged, as a wrapper, which is managed, and is successfully installed via nuget. Currently if we manually copy in libtidy.dll into bin, it works fine, but it would be better if the build process pulled in libtidy.dll, perhaps as part of the Tidymanaged install, which it does not at present.
EDIT2
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;
EDIT3
Edit 3:
I am
a) placing libtidy.dll
and Install.ps1
in a directory called nuget-libtidy
in the manifest generated by nuget spec
I have:
<?xml version="1.0"?>
<package >
<metadata>
<id>nuget-libtidy</id>
<version>1.0.0</version>
<authors>Name</authors>
<owners>Name</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>nuget-libtidy</description>
<copyright>Copyright 2016</copyright>
<tags>nuget-libtidy</tags>
</metadata>
<files>
<file src="libtidy.dll" target="content" />
<file src="Install.ps1" target="tools" />
</files>
</package>
When I run nuget pack
I get the following warning:
WARNING: 1 issue(s) found with package 'nuget-libtidy2'.
Issue: Assembly outside lib folder.
Description: The assembly 'content\libtidy.dll' is not inside the 'lib' folder and hence it won't be added as reference when the package is installed into a project.
Solution: Move it into the 'lib' folder if it should be referenced.
b) When we build the application libtidy.dll is placed in the root of the project (not the bin) & get the following error in the output window:
Added package 'nuget-libtidy' to 'packages.config'
Executing script file <path>\nuget-libtidy\tools\Install.ps1'...
Cannot add a link to the file libtidy.dll. There is already a file of the same name in this folder.
At <path>\nuget-libtidy\tools\Install.ps1:7 char:5
+ $project.ProjectItems.AddFromFile("libtidy.dll");
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
Successfully installed 'nuget-libtidy' to <Namepace>