excelmsbuildmsbuild-taskexcel-dna

How to auto build Excel-DNA addin in VS 2019


I am trying to auto pack Excel-DNA project.

I have followed Getting Started with Excel-DNA to create Excel-DNA project.

I followed Excel-DNA Packing Tool to pack my project which works.

I am trying to use VS 2019 post-build event to achieve auto pack my project.

I copied the ExcelDna.Integration.dll,ExcelDnaPack.exe and ExcelDnaPack.exe.config to my folder, and then use command below

ECHO "Start Deploy"
"$(SolutionDir)Distribution\ExcelDnaPack.exe" "$(TargetDir)$(TargetName)-AddIn.dna" /Y /O "$(TargetDir)DeployMeekou.ExcelCOM.xll"

But, it create the expected file. But, I got this file is invalid when I try to load it from Excel.

And checking build output, this is the output

1>  "Start Deploy"
1>  Using base add-in C:\Users\xx\Meekou.ExcelCOM\bin\Debug\Meekou.ExcelCOM-AddIn.xll
1>  System.ComponentModel.Win32Exception: The parameter is incorrect
1>     at ResourceHelper.ResourceUpdater.RemoveResource(String typeName, String name)
1>     at ExcelDnaPack.PackProgram.Pack(String[] args)
1>     at ExcelDnaPack.PackProgram.Main(String[] args)

Here are my project folder

enter image description here


Solution

  • The best way these days to make a new Excel-DNA add-in is to use the "ExcelDna.AddIn" package on NuGet.

    If you start with a new "Class Library (.NET Framework)" project, and install the package, it should just work and all the packing etc. steps are built in.

    If you are using the new SDK-style project files or PackageReference style NuGet references (instead of a packages.config file) then you'll need the prerelease version 1.6.0-Preview2 or later of the ExcelDna.AddIn package.

    The best place to ask questions about Excel-DNA is the Google group at https://groups.google.com/g/exceldna