Closed LastsForever closed 8 months ago
I don't know Rider or Chinese, so it's really hard for me to support. One problem is that Rider does not install the NuGet package correctly. You can try to fix this by:
Thank you! It works well with it. But I still wondering 1) if there is a way to edit some config file to build the xll file automaticly in Rider. 2) if it can be done in Visual Studio. It seems that there's no default way to create a .net framework class library with F#.
Finally I found that the project builded without error, but the xll file didn't work. Maybe there's still something wrong with Rider.
The content of the file UDF.dna is:
<?xml version="1.0" encoding="utf-8"?>
<DnaLibrary Name="%ProjectName% Add-In" RuntimeVersion="v4.0" xmlns="http://schemas.excel-dna.net/addin/2018/05/dnalibrary">
<ExternalLibrary Path="UDFs.dll" ExplicitExports="false" LoadFromBytes="true" Pack="true" IncludePdb="false" />
<!--
The RuntimeVersion attribute above allows two settings:
* RuntimeVersion="v4.0" - for .NET 4 and 4.5
* RuntimeVersion="v2.0" - for .NET 2.0, 3.0 and 3.5
You can have IntelliSense (autocomplete) and validation for this file.
See https://github.com/Excel-DNA/ExcelDna/tree/master/Distribution/XmlSchemas/
Additional referenced assemblies can be specified by adding 'Reference' tags.
These libraries will not be examined and registered with Excel as add-in libraries,
but will be packed into the -packed.xll file and loaded at runtime as needed.
For example:
<Reference Path="Another.Library.dll" Pack="true" />
Excel-DNA also allows the XML for ribbon UI extensions to be specified in the .dna file.
See the main Excel-DNA site at http://excel-dna.net for downloads of the full distribution.
-->
</DnaLibrary>
The content of the file Library.fs is:
namespace UDFs
open System
open ExcelDna.Integration
type Class() =
[<ExcelFunction(Category="FSharp Functions", Description="FSharp function to add numbers")>]
let add x y = x + y
It looks like the <DnaLibrary Name="%...." />
should also be fixed.
Then the function must be static for it to be recognized by Excel-DNA. Top-level code in a module would also work.
Try this as your F# source file:
module MyFunctions
open ExcelDna.Integration
[<ExcelFunction(Description="My first .NET function")>]
let HelloDna name =
"Hello " + name
It looks like the
<DnaLibrary Name="%...." />
should also be fixed.Then the function must be static for it to be recognized by Excel-DNA. Top-level code in a module would also work.
Try this as your F# source file:
module MyFunctions open ExcelDna.Integration [<ExcelFunction(Description="My first .NET function")>] let HelloDna name = "Hello " + name
Cool!!!
I used Rider to create a .Net Framework Class Library, and tried to compile the xll file but failed. Here is the log file: ` 生成启动时间为 2020/11/15 12:32:33。 日志记录详细程度设置为: Normal。 1>项目“C:\Users\Victor\Documents\scripts\fsharp\ExcelAddIn\UDFs\UDFs.fsproj”在节点 1 上(build 个目标)。 1>GenerateTargetFrameworkMonikerAttribute: 正在跳过目标“GenerateTargetFrameworkMonikerAttribute”,因为所有输出文件相对于输入文件而言都是最新的。 CoreCompile: C:\Users\Victor\Documents\scripts\fsharp\ExcelAddIn\UDFs\packages\FSharp.Compiler.Tools.10.0.2\build..\tools\fsc.exe -o:obj\Debug\UDFs.dll -g --debug:portable --noframework --define:DEBUG --define:TRACE --optimize- --tailcalls- -r:C:\Users\Victor\Documents\scripts\fsharp\ExcelAddIn\UDFs\packages\ExcelDna.Integration.1.1.0\lib\ExcelDna.Integration.dll -r:C:\Users\Victor\Documents\scripts\fsharp\ExcelAddIn\UDFs\packages\FSharp.Core.4.5.2\lib\net45\FSharp.Core.dll -r:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\mscorlib.dll -r:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Core.dll -r:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.dll -r:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Numerics.dll --target:library --warn:3 --warnaserror:76 --fullpaths --flaterrors --subsystemversion:6.00 --highentropyva+ --warnon:1182 AssemblyInfo.fs Library.fs obj\Debug.NETFramework,Version=v4.5.AssemblyAttributes.fs
生成失败。
已用时间 00:00:04.10
`