Why can't the GitHub Workflow find the Excel assembly?

Falanga, Rod, DOH 245 Reputation points
2023-12-21T15:55:45.28+00:00

8 years ago I inherited a legacy VB.NET ASP.NET application. I never met the original developer(s), so there was no hand-off. And whoever they were, the didn't bother to document anything.

Anyway, we're working on migrating all of our source code out of our old version of TFS, into our new GitHub Enterprise organizations. Hundreds of projects have been migrated. I've been working on writing a GitHub Workflow to build the app with. Because this is an old .NET Framework app, I've taken their template and made the necessary changes to build it with .NET Framework 4.5 and 4.5.2. But it fails to find Excel. (Excel is used to generate one of the reports.) This is the a part of the error (I've shorten it for brevity's sake):

Warning: D:\a\FP_Timetrack\FP_Timetrack\WicReports\Utilities.vb(3,9): warning BC40056: Namespace or type specified in the Imports 'Microsoft.Office.Interop' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases. [D:\a\FP_Timetrack\FP_Timetrack\WicReports\WicReports.vbproj] Error: D:\a\FP_Timetrack\FP_Timetrack\WicReports\Utilities.vb(493,22): error BC30002: Type 'Excel.Application' is not defined. [D:\a\FP_Timetrack\FP_Timetrack\WicReports\WicReports.vbproj] Error: D:\a\FP_Timetrack\FP_Timetrack\WicReports\Utilities.vb(494,21): error BC30002: Type 'Excel.Workbook' is not defined. [D:\a\FP_Timetrack\FP_Timetrack\WicReports\WicReports.vbproj] Error: D:\a\FP_Timetrack\FP_Timetrack\WicReports\Utilities.vb(495,18): error BC30002: Type 'Excel.Worksheet' is not defined. [D:\a\FP_Timetrack\FP_Timetrack\WicReports\WicReports.vbproj] Error: D:\a\FP_Timetrack\FP_Timetrack\WicReports\Utilities.vb(501,16): error BC30002: Type 'Excel.Range' is not defined. [D:\a\FP_Timetrack\FP_Timetrack\WicReports\WicReports.vbproj] Error: D:\a\FP_Timetrack\FP_Timetrack\WicReports\Utilities.vb(517,35): error BC30002: Type 'Excel.Worksheet' is not defined. [D:\a\FP_Timetrack\FP_Timetrack\WicReports\WicReports.vbproj] Error: D:\a\FP_Timetrack\FP_Timetrack\WicReports\Utilities.vb(524,49): error BC30002: Type 'Excel.Worksheet' is not defined. [D:\a\FP_Timetrack\FP_Timetrack\WicReports\WicReports.vbproj] Error: D:\a\FP_Timetrack\FP_Timetrack\WicReports\Utilities.vb(565,33): error BC30451: 'Excel' is not declared. It may be inaccessible due to its protection level. [D:\a\FP_Timetrack\FP_Timetrack\WicReports\WicReports.vbproj] Error: D:\a\FP_Timetrack\FP_Timetrack\WicReports\Utilities.vb(614,22): error BC30002: Type 'Excel.Application' is not defined. [D:\a\FP_Timetrack\FP_Timetrack\WicReports\WicReports.vbproj]

Looking at the project in Visual Studio 2022, I can see the reference to Microsoft.Office.Interop.Excel fine. Also, I didn't edit the project that generates the Excel report. It's the code from the original developer.

So, I don't know why the GitHub Action cannot find it. I could use help with this, please.

Microsoft 365 and Office Excel For business Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Falanga, Rod, DOH 245 Reputation points
    2023-12-21T18:45:57.49+00:00

    I found this post on Stack Overflow which recommended use NuGet to pull in Excel. I thought that the original developer had done that, but I guess not. They must have done something different, like just look for Excel in Visual Studio references, or something. Anyway, including it with NuGet fixed my issue.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.