Is it possible to use NuGet to distribute a COM DLL?
How would I setup the package?
I'm thinking that I could put the DLL in the Tools directory, then run a post-install script to register the library, but I'm not very good at PowerShell.
Are there any online examples of how to do this (if its possible)?
Put simply, a NuGet package is a single ZIP file with the . nupkg extension that contains compiled code (DLLs), other files related to that code, and a descriptive manifest that includes information like the package's version number.
You can configure Visual Studio to automatically generate the NuGet package when you build the project. In Solution Explorer, right-click the project and choose Properties. In the Package tab, select Generate NuGet package on build.
A dynamic-link library (DLL) file contains a shared library of functions that can be used by Windows programs. The DLL package uses a . dll file as reference and calls functions from the bot.
When I faced a similar problem I created a NuGet package with the following structure.
The MYCOMLib.dll is a interop DLL generated from the mycom.dll with the Type Library Importer (tlbimp.exe). This is simply done with the command :
Tlbimp mycom.dll
The install.ps1 contains the following code:
param($installPath, $toolsPath, $package, $project) regsvr32 Join-Path $toolsPath '\mycom.dll' /s $project.Object.References | Where-Object { $_.Name -eq "MYCOMLib" } | ForEach-Object { $_.EmbedInteropTypes = $false }
What this script does is that it registers the COM dll and sets the EmbedInteropTypes property on the reference to false, which is necessary when using .NET 4. See Interop type cannot be embedded for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With