Skip to content

NativeAOT preview: Review NuGet package usage #833

Open

Description

@govert

Posted by Codex agent on behalf of @govert

In the 1.10.0-preview1 NativeAOT setup, ExcelDnaToolsPath ends up resolving to the ExcelDna.AddIn.NativeAOT package tools\ folder by default, but the MSBuild tasks still need ExcelDna.xll / ExcelDna64.xll from the ExcelDna.AddIn package.

Observed behavior

  • ExcelDna.AddIn.targets sets default: ExcelDnaToolsPath = $(MSBuildThisFileDirectory)..\tools\
  • ExcelDna.AddIn.NativeAOT.targets also sets the same default.
  • When both packages are referenced, the NativeAOT targets can effectively win and ExcelDnaToolsPath points at ...\.nuget\packages\exceldna.addin.nativeaot\<ver>\tools\.
  • exceldna.addin.nativeaot\tools\net6.0-windows7.0\ contains ExcelDna.AddIn.Tasks.dll etc, but does not contain ExcelDna.xll.
  • Build then fails sanity checks with:
    File does not exist (Xll32FilePath): ...\.nuget\packages\exceldna.addin.nativeaot\1.10.0-preview1\tools\net6.0-windows7.0\ExcelDna.xll

Repro (minimal)

  • Create an add-in project that references:
    • ExcelDna.AddIn 1.10.0-preview1
    • ExcelDna.Integration 1.10.0-preview1
    • ExcelDna.AddIn.NativeAOT 1.10.0-preview1
  • TargetFramework tested with net10.0-windows7.0, RuntimeIdentifier=win-x64, PublishAot=true, SelfContained=true.
  • Run: dotnet restore -r win-x64 then dotnet build -c Release -r win-x64.

Workaround
Add this to the project to force the base tools path to the ExcelDna.AddIn package:

<PropertyGroup>
  <ExcelDnaToolsPath>$(PkgExcelDna_AddIn)\tools\</ExcelDnaToolsPath>
</PropertyGroup>

Suggested fixes
Option A

  • Have ExcelDna.AddIn.NativeAOT package include ExcelDna.xll / ExcelDna64.xll (and any other required base loader assets) in the expected tools\net6.0-windows7.0\ layout.

Option B

  • Change ExcelDna.AddIn.NativeAOT.targets to not override ExcelDnaToolsPath if ExcelDna.AddIn is referenced, or to default ExcelDnaToolsPath to $(PkgExcelDna_AddIn)\tools\ when that property exists.

Option C

  • Split the notion of tool paths: one for core ExcelDna loader/tools (ExcelDna.AddIn) and a separate one for NativeAOT-specific tooling, so the tasks do not fight over a single ExcelDnaToolsPath.

Notes

  • ExcelDna.AddIn.NativeAOT.targets already uses ExcelDnaNativeAOT64.xll for the packing step (Xll64FilePath="$(ExcelDnaToolsPath)ExcelDnaNativeAOT64.xll"). The failure is specifically around the missing base ExcelDna.xll when ExcelDnaToolsPath points at the NativeAOT package.

Activity

  1. changed the title [-]NativeAOT preview: ExcelDnaToolsPath defaults to NativeAOT package tools, but ExcelDna.xll lives in ExcelDna.AddIn[/-] [+]NativeAOT preview: Review NuGet package usage[/+] on Feb 18, 2026
  2. govert commented on Feb 18, 2026

    @govert
    MemberAuthor

    @Sergey-Vlasov

    This seems to be a problem when we have both packages in the project.
    It might also be a problem introduced during NuGet package publishing of the preview.

    When we have this project file

    <Project Sdk="Microsoft.NET.Sdk">
    
      <PropertyGroup>
        <TargetFramework>net10.0-windows</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
    
        <RuntimeIdentifier>win-x64</RuntimeIdentifier>
        <PublishAOT>true</PublishAOT>
      </PropertyGroup>
    
      <ItemGroup>
        <PackageReference Include="ExcelDna.AddIn" Version="1.10.0-preview1" />
        <PackageReference Include="ExcelDna.AddIn.NativeAOT" Version="1.10.0-preview1" />
      </ItemGroup>
    
    </Project>
    

    We get this compile error

    1>MSBUILD : ExcelDnaBuild error DNA731704007: File does not exist (Xll32FilePath): C:\Users\GovertvanDrimmelen\.nuget\packages\exceldna.addin.nativeaot\1.10.0-preview1\build\..\tools\\net6.0-windows7.0\ExcelDna.xll
    1>MSBUILD : ExcelDnaBuild error DNA731704007: System.InvalidOperationException: File does not exist (Xll32FilePath): C:\Users\GovertvanDrimmelen\.nuget\packages\exceldna.addin.nativeaot\1.10.0-preview1\build\..\tools\\net6.0-windows7.0\ExcelDna.xll
    1>MSBUILD : ExcelDnaBuild error DNA731704007:    at ExcelDna.AddIn.Tasks.CreateExcelAddIn.RunSanityChecks()
    1>MSBUILD : ExcelDnaBuild error DNA731704007:    at ExcelDna.AddIn.Tasks.CreateExcelAddIn.Execute()
    

    I suppose one would like to build the add-in such that publishing with NativeAOT is an optional extra step, but the project still works as a non-NativeAOT project until you publish. This seems like more than we have in place now, but it would be good to clarify the intent of the current preview, and then consider what we want eventually.

  3. Sergey-Vlasov commented on Feb 22, 2026

    @Sergey-Vlasov
    Contributor

    I suggest to use a separate configuration for AOT when including both ExcelDna.AddIn and ExcelDna.AddIn.NativeAOT packages in a single project:

    <Project Sdk="Microsoft.NET.Sdk">
    
      <PropertyGroup>
        <TargetFramework>net10.0-windows</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
        <Configurations>Debug;Release;ReleaseAOT</Configurations>
      </PropertyGroup>
    
      <PropertyGroup Condition="'$(Configuration)' == 'ReleaseAOT'">
        <RuntimeIdentifier>win-x64</RuntimeIdentifier>
        <PublishAOT>true</PublishAOT>
        <SelfContained>true</SelfContained>
      </PropertyGroup>
    
      <ItemGroup Condition="'$(Configuration)' != 'ReleaseAOT'">
        <PackageReference Include="ExcelDna.AddIn" Version="1.10.0-preview1" />
      </ItemGroup>
    
      <ItemGroup Condition="'$(Configuration)' == 'ReleaseAOT'">
        <PackageReference Include="ExcelDna.AddIn.NativeAOT" Version="1.10.0-preview1" />
      </ItemGroup>
    
      <Target Condition="'$(Configuration)' == 'ReleaseAOT'" Name="SetNoBuild">
        <PropertyGroup>
          <NoBuild>true</NoBuild>
        </PropertyGroup>
      </Target>
      <Target Condition="'$(Configuration)' == 'ReleaseAOT'" Name="PublishAfterBuild" AfterTargets="AfterBuild" DependsOnTargets="SetNoBuild;Publish" />
    
    </Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions