Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can NuGet distribute a COM dll?

Tags:

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)?

like image 762
Jim Counts Avatar asked May 17 '11 21:05

Jim Counts


People also ask

Are NuGet packages DLL?

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.

How do I create a NuGet package from a DLL in Visual Studio 2017?

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.

Is a DLL a package?

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.


1 Answers

When I faced a similar problem I created a NuGet package with the following structure.

  • lib
    • MYCOMLib.dll
  • tools
    • mycom.dll
    • install.ps1

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.

like image 131
hskan Avatar answered Sep 23 '22 14:09

hskan