Upgrade From Version 1.1 to 1.6: Wildcards in Reference Paths

249 views
Skip to first unread message

cmdty

unread,
Jan 5, 2023, 1:23:05 AM1/5/23
to Excel-DNA
I'm just upgrading my reference from Excel DNA 1.1 to 1.6 and noticed that the ability to put wildcards in reference paths no longer works. Was this feature removed in a version upgrade? I do see a GitHub issue to add this feature, including links to workarounds, but just wanted to confirm.

Govert van Drimmelen

unread,
Jan 6, 2023, 8:46:58 AM1/6/23
to exce...@googlegroups.com

--------------------------------------------------

Excel-DNA is now registered on GitHub Sponsors.

Please sign up for a monthly contribution – this encourages further development and support.

--------------------------------------------------

 

Hi there,

 

The feature you are talking about is to put a wildcard in the <Reference> tag in a .dna file, like this:

 

<?xml version="1.0" encoding="utf-8" ?>

<DnaLibrary>

                <ExternalLibrary Path="MyLibrary.dll" Pack="true" />

                <Reference Path="Libraries\*.dll" Pack="true" />

</DnaLibrary>

 

I think the path here is interpreted relative to the project root directory, not the output directory.

 

The feature was not removed, and the code is still in place, as you can see here:

https://github.com/Excel-DNA/ExcelDna/blob/c7705c665a196f14fe10b215ac7c2bd10efa0d5e/Source/ExcelDna.PackedResources/ExcelDnaPack.cs#L297

 

One thing that was a bit of a regression in v1.6.0 was the build output from the ExcelDnaPack task – it no longer showed the individual files being packed in the build output window. This has been fixed subsequently, so it works better in the latest version 1.6.1-beta2.

 

There might be some other regression that you’re seeing.

If so, maybe you can make a small project that build correctly under v1.1 and fails under the current version.

 

If you are moving to SDK-style project files, there are different ways to add extra files for the packing.

 

  1. You can specify a list of file names (but no wildcards) in an ExcelAddInInclude property:

 

  <PropertyGroup>

      <ExcelAddInInclude>SDKExcelAddInName.dll;SDKExcelAddInFileName.dll</ExcelAddInInclude>

  </PropertyGroup>

 

  1. You can set up a target to enumerate a wildcard, which will then build the include list with all the .dlls automatically:

 

  <Target Name="PackedReferences" AfterTargets="AfterBuild" BeforeTargets="ExcelDnaBuild">

    <ItemGroup>

      <References Include="$(OutDir)*.dll" Exclude="$(OutDir)$(TargetFileName)"/>

    </ItemGroup>

 

    <PropertyGroup>

      <ExcelAddInInclude>@(References)</ExcelAddInInclude>

    </PropertyGroup>

  </Target>

 

  1. If you are targeting .NET 6 we have also added a mechanism to pack the managed and native dependencies according to the .deps.json dependency file that the .NET 6 build geenrates.

To enable this feature you set the following properties in the project files:

 

        <ExcelDnaPackNativeLibraryDependencies>true</ExcelDnaPackNativeLibraryDependencies>

        <ExcelDnaPackManagedDependencies>true</ExcelDnaPackManagedDependencies>

 

      The result will be that the right platform and architecture-specific dependencies will be packed automatically.

 

-Govert

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/bdd699be-7da9-40fd-917a-38c780f46872n%40googlegroups.com.

cmdty

unread,
Jan 6, 2023, 4:45:33 PM1/6/23
to Excel-DNA
Hi Govert,

Many thanks for your detailed response. This give me plenty of information to investigate further. I will be using an SDK-style project, and in keeping with this I particularly like the Reference Item Group way of doing it.

In fact, I think I know the problem after properly reading the version 1.6 blog post. I'm using an SDK-style project, but was also editing the DNA file, but I see from this post that for SDK-style projects it is the csproj properties and item groups which are used to generate the DNA file. Sorry, that's my bad for not seeing this before.

Why is GitHub issue #402 still open if wild cards in reference paths is working?

Regards,

Jake
Reply all
Reply to author
Forward
0 new messages