我想创建一个将dll引用添加到Visual Studio和.net的类型库中的nuget。现在通常您会使用reserve32 nameof.dll,有没有一种方法可以通过nuget包资源管理器来实现呢?
我通常会在管理命令提示符下运行此命令
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>
然后,我应该能够在Visual Studio中的com的引用部分中看到它,如下所示,以帮助我加快不必总是注册每个项目的速度。
根据以下屏幕截图
编辑2
我找到了此代码,该代码应允许它通过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 }
但是我应该在哪里放置此代码,以及如何调整它以考虑到我所有的dll。因为它们都需要调用regsvr32.dll。
答案 0 :(得分:0)
请参阅Can NuGet distribute a COM dll?
我永远找不到在MS网站上清楚记录的位置,但这是我所做的:
nuget软件包将在安装过程中运行ps1脚本。如果要将dll添加为要导入nuget包的项目的引用,则将其放在“ lib”文件夹中(与“工具”同级)。
另请参阅https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package#create-the-nuspec-file