I am trying to use github actions to deploy a dotnet app which has a dependency on at 32 bit COM Dll.
I register the DLl with RegSvr32, which seems to work. (I do not get an exception)
but then I get the following exception during the build:
Run msbuild path/to/my.csproj /p:Configuration=Release
MSBuild version 17.11.9+a69bbaaf5 for .NET Framework
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(3040,5): warning MSB3284: Cannot get the file path for type library "0a67e301-3ecb-47be-bba9-dc67ff219358" version 1.0. Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))
What worked for me was copying the dll to SysWow Directory:
- name: Copy DLL to SysWoW64
run: |
$dllPath = "${{ github.workspace }}\path\to\dllName.dll"
$destinationPath = "$env:SystemRoot\SysWoW64\dllName.dll"
Copy-Item -Path $dllPath -Destination $destinationPath -Force
if (Test-Path $destinationPath) {
Write-Output "DLL copied to $destinationPath"
} else {
Write-Error "Failed to copy DLL to $destinationPath"
exit 1
}
- name: Register COM DLL (32-bit)
run: |
$dllPath = "$env:SystemRoot\SysWoW64\DllName.dll"
$outputFile = "${{ github.workspace }}\regsvr32_output.txt"
Start-Process -FilePath "C:\Windows\SysWOW64\regsvr32.exe" -ArgumentList "/s", $dllPath -Wait -NoNewWindow -PassThru | Out-File $outputFile
$exitCode = $LastExitCode
Get-Content $outputFile
As an aside, you have to use msbuild if the project is referencing a COM dll.
- name: Set up MSBuild
uses: microsoft/setup-msbuild@v1
# other steps ...
- name: Build and Publish
run: msbuild path/to/ProjectName.csproj /t:Publish /p:Configuration=Release /p:OutputPath=./publish