Relative Paths in .dna file

57 views
Skip to first unread message

Maddin EmPunkt

unread,
Sep 27, 2022, 12:48:32 PM9/27/22
to Excel-DNA
Hi there,

I am trying to reference an assembly in \.nuget\packages but I cannot seem to get the .dna file to accept relative paths.

The location of the assembly to be referenced:
C:\Users\user_name\.nuget\packages\package_name\version\lib\net6.0\package_name.dll

My .dna file is located in:
C:\Repositories\repo\Project\ExcelDNA.dna

<DnaLibrary RuntimeVersion="v4.0" Name="MyProject" Language="CS">
  <ExternalLibrary Path="ExcelInterface.dll" />
  <Reference Path="package_name.dll" />
</DnaLibrary>

Using absolute path works for me. i.e. this works:

<DnaLibrary RuntimeVersion="v4.0" Name="MyProject" Language="CS">
  <ExternalLibrary Path="ExcelInterface.dll" />
  <Reference Path=" C:\Users\user_name\.nuget\packages\package_name\version\lib\net6.0\package_name.dll  " />
</DnaLibrary>

Sorry for rookie question.

Govert van Drimmelen

unread,
Sep 28, 2022, 2:48:13 AM9/28/22
to Excel-DNA
Hi Martin,

If you add the package in question as a PackageReference your project, the assembly you need should be copied to your output directory together with your own library and the .xll files.
From there it should work to just add the name of the assembly, and it will be discovered directly from the output directory.
Otherwise I'm not sure how the pack process would discover the file inside the NuGet package cache, just from the file name.

-Govert

Maddin EmPunkt

unread,
Sep 28, 2022, 2:57:39 AM9/28/22
to Excel-DNA
Hi Govert,

thanks for your quick reply.
The package in question is only implicitly referenced via another project reference. I.e. MyProject references project Maths which references package_name.
Do you happen to know a way to "force" copy all (implicitly) referenced assemblies to be copied to my output directory?

I was hoping I could avoid copying assemblies left and right and refer to the packages in /.nuget/packages directly but maybe I was too optomistic.

Martin
Reply all
Reply to author
Forward
0 new messages