Excel-DNA / Excel-DNA/ExcelDna
NativeAOT preview: Review NuGet package usage
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 292
- Avg merge
- 20d 12h
- Merged PRs (30d)
- 1
Description
*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\\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:
```xml
$(PkgExcelDna_AddIn)\tools\
```
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.
Contributor guide
Assessment
This issue has not been assessed yet.