0

I am wanting to create a nuget that adds a dll reference into the type libary of visual studio and .net. Now normally you would use reserve32 nameof.dll is there a way to achieve this with nuget package explorer

I would normally run this command from an administrative comcmand prompt

regsvr32 nameof.dll

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
  <metadata>
    <id>MyPackage</id>
    <version>1.0.0</version>
    <title></title>
    <authors>User</authors>
    <owners>User</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>My package description.</description>
  </metadata>
  <files>
    <file src="build\_._" target="build\_._" />
    <file src="content\Sage50ApplicationObject.chm" target="content\Sage50ApplicationObject.chm" />
    <file src="content\SageDataObjects2017.chm" target="content\SageDataObjects2017.chm" />
    <file src="content\SageDataObjectsv24.chm" target="content\SageDataObjectsv24.chm" />
    <file src="content\SageDataObjectsv25.chm" target="content\SageDataObjectsv25.chm" />
    <file src="lib\SdoEng170.tlb" target="lib\SdoEng170.tlb" />
    <file src="lib\SdoEng200.tlb" target="lib\SdoEng200.tlb" />
    <file src="lib\SdoEng220.tlb" target="lib\SdoEng220.tlb" />
    <file src="lib\SdoEng230.tlb" target="lib\SdoEng230.tlb" />
    <file src="lib\SdoEng240.tlb" target="lib\SdoEng240.tlb" />
    <file src="lib\SdoEng250.tlb" target="lib\SdoEng250.tlb" />
    <file src="lib\sg50SdoEngine170.dll" target="lib\sg50SdoEngine170.dll" />
    <file src="lib\sg50SdoEngine200.dll" target="lib\sg50SdoEngine200.dll" />
    <file src="lib\sg50SdoEngine220.dll" target="lib\sg50SdoEngine220.dll" />
    <file src="lib\sg50SdoEngine230.dll" target="lib\sg50SdoEngine230.dll" />
    <file src="lib\sg50SdoEngine240.dll" target="lib\sg50SdoEngine240.dll" />
    <file src="lib\sg50SdoEngine250.dll" target="lib\sg50SdoEngine250.dll" />
   </files>
</package>

I then should be able to see it in the references section of the com in visual studio as per below its to help me speed up not always having to register these each project.

As per below screen shot

enter image description here

Edit 2

I found this code which should allow it to process the command through powershell.

param($installPath, $toolsPath, $package, $project)

regsvr32 Join-Path $toolsPath '\mycom.dll' /s

$project.Object.References | Where-Object { $_.Name -eq "MYCOMLib" } |  ForEach-Object { $_.EmbedInteropTypes = $false }

But where do i place this code and how can I adjust it to take into account all my dlls. As they all require regsvr32.dll to be called.

Dave
  • 233
  • 2
  • 12

1 Answers1

0

see Can NuGet distribute a COM dll?

I could never find where this is clearly documented on the MS site, but here's what I did:

  • Create a folder and add the nuspec file to it.
  • Then create a subfolder: tools.
  • Put your dlls in the tools folder.
  • Name your Powershell script file 'install.ps1' and put it in the tools folder.

The nuget package will run the ps1 script during its install process. Put the dlls in a 'lib' folder (sibling to 'tools') if you want to add them as references to the project you're importing the nuget package into.

see also https://learn.microsoft.com/en-us/nuget/create-packages/creating-a-package#create-the-nuspec-file

sartoris
  • 816
  • 1
  • 7
  • 21