Excel-DNA / ExcelDna

Excel-DNA - Free and easy .NET for Excel. This repository contains the core Excel-DNA library.
https://excel-dna.net
zlib License
1.26k stars 272 forks source link

System.Reflection.Metadata in NuGet package for build #589

Open govert opened 1 year ago

govert commented 1 year ago

We have this as a dependency of our build task, but we're not shipping the library in the NuGet package. The build normally seems to work fine, but this discussion makes me ask whether we are supposed to ship it or not. How would we know whether this is expected to be available in the build environment?

Sergey-Vlasov commented 1 year ago

As I understand, System.Reflection.Metadata comes with .NET Core and VS MSBuild.

I’m (unfortunately?) can’t reproduce the problem from the discussion on my machine(s). Tried VS 2022 17.1.6 and VS 2019 too.

And without experiencing the problem, I can’t try to see if adding System.Reflection.Metadata.dll to our package will help or not.

Michael-Kempe commented 5 months ago

Hi, I see the same error when building my project on VS2019 v16.11.32.

Adding a reference to the project does not help - also adding System.Reflection.Metadata.dll v6.0.0.0 to the Excel DNA Package Folder (ExcelDna.AddIn.1.7.0\tools\net452) does not work.

My project: AnyCPU .Net Framework v4.7.2 VS 2019 v16.11.32

My project worked with ExcelDna.AddIn v1.6

Any suggestions?

Here's the error message: Severity Code Description Project File Line Suppression State Error System.IO.FileNotFoundException: Could not load file or assembly 'System.Reflection.Metadata, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. File name: 'System.Reflection.Metadata, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at ExcelDna.PackedResources.ExcelDnaPack.IsAssembly(String path, Boolean& isPE) at ExcelDna.PackedResources.ExcelDnaPack.IsNativeLibrary(String path) at ExcelDna.PackedResources.ExcelDnaPack.PackDnaLibrary(String dnaPath, Byte[] dnaContent, String dnaDirectory, ResourceUpdater ru, Boolean compress, Boolean multithreading, List1 filesToPublish, Boolean packManagedDependencies, String[] dependenciesToExcludeParam, String outputBitness, IBuildLogger buildLogger) at ExcelDna.PackedResources.ExcelDnaPack.Pack(String dnaPath, String xllOutputPathParam, Boolean compress, Boolean multithreading, Boolean overwrite, String usageInfo, List1 filesToPublish, Boolean packNativeLibraryDependencies, Boolean packManagedDependencies, String excludeDependencies, Boolean useManagedResourceResolver, String outputBitness, IBuildLogger buildLogger) at ExcelDna.AddIn.Tasks.PackExcelAddIn.Execute()

=== Pre-bind state information === LOG: DisplayName = System.Reflection.Metadata, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (Fully-specified) LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/MSBuild/Current/Bin/ LOG: Initial PrivatePath = NULL Calling assembly : ExcelDna.AddIn.Tasks, Version=1.1.0.0, Culture=neutral, PublicKeyToken=f225e9659857edbe.

LOG: This bind starts in LoadFrom load context. WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load(). LOG: Using application configuration file: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe.Config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Post-policy reference: System.Reflection.Metadata, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a LOG: The same bind was seen before, and was failed with hr = 0x80070002. Test.Excel

govert commented 5 months ago

@Michael-Kempe Thanks for reporting that you're running into this problem too. I'll have to test with a clean machine and VS 2019 installation to see if this can be reproduced.

My only immediate suggestion is to build with VS 2022, or maybe from a 'dotnet build' command line.

Sergey-Vlasov commented 5 months ago

I've retested it with VS 2019 on my main workstation and on a clean VM with the project attached and still can't reproduce the problem. Wondering what may cause it...

MyAddin.zip