Thanks Govert,
The 2) F# error was a typo on my part, which I fixed. But the rest did not seem to fix the issue. It always seems to come from .fsproject file (e.g. I realized the impact of the <IncludeAssets> tag, please see below).
So I recreated another similar project, Library11:
1) I changed .fs file back to our original program
namespace Library11
module MyFunctions =
open ExcelDna.Integration
[<ExcelFunction(Description="My first .NET function")>]
let HelloDna name =
"Hello " + name
2) the original, out-of-the-box, unaltered project .fsproject file is
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Include="Library1.fs" />
<None Include="Script.fsx" />
</ItemGroup>
</Project>
3) Loading ExcelDna from NuGet
I now have the error message:
Error DNA1546 Excel-DNA is not compatible with projects that use NuGet `PackageReference`. Make sure you create a .NET Framework (Class Library) project and configure Visual Studio to use `packages.config` Library11 C:\Users\W1\.nuget\packages\exceldna.addin\1.1.1\build\ExcelDna.AddIn.targets
while the .fsproject was automatically updated to
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Include="Library1.fs" />
<None Include="Script.fsx" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ExcelDna.AddIn" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
(added lines in bold-face)
4) I then manually edited the .fsproject file to allow Package references.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>
<ExcelDnaAllowPackageReferenceProjectStyle>true</ExcelDnaAllowPackageReferenceProjectStyle>
<RunExcelDnaSetDebuggerOptions>false</RunExcelDnaSetDebuggerOptions>
</PropertyGroup>
<ItemGroup>
<Compile Include="Library1.fs" />
<None Include="Script.fsx" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ExcelDna.AddIn" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
That removed the original error.
But two new other errors appeared:
Error FS0039 The namespace or module 'ExcelDna' is not defined. Library11 C:\Users\W1\source\repos\Library11\Library1.fs
Error FS0039 The type 'ExcelFunction' is not defined. Library11 C:\Users\W1\source\repos\Library11\Library1.fs
5) In order to get rid of these other errors, I manually removed the <IncludeAssets> tags from the .fsproject (I got that trick from you on [2])
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>
<ExcelDnaAllowPackageReferenceProjectStyle>true</ExcelDnaAllowPackageReferenceProjectStyle>
<RunExcelDnaSetDebuggerOptions>false</RunExcelDnaSetDebuggerOptions>
</PropertyGroup>
<ItemGroup>
<Compile Include="Library1.fs" />
<None Include="Script.fsx" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ExcelDna.AddIn" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<!--<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>-->
</PackageReference>
</ItemGroup>
</Project>
6) At this stage the project does compile :
Build started...
1>------ Build started: Project: Library11, Configuration: Debug Any CPU ------
1>Library11 -> C:\Users\W1\source\repos\Library11\bin\Debug\net48\Library11.dll
1>---
1>ExcelDnaBuild: ---
1>---
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
7) However it does not seem to generate any .xll file.
(I am not even trying to start the debugger and open an Excel sheet to test the addin at this stage, it's just that there is apparently no ExcelDna .xll to be found in the project).
What else could it be? Thanks for your help.
Jan