如何生成F#签名文件(不使用Visual Studio)

编程入门 行业动态 更新时间:2024-10-25 06:29:06
本文介绍了如何生成F#签名文件(不使用Visual Studio)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在MacOS上使用JetBrains Rider,并尝试使用Scott Wlaschin的代码功能强大的域建模

I' m using JetBrains Rider on MacOS and experimenting with code from Scott Wlaschin Domain Modelling Made Functional

这是我的模块定义及其相关性:

Here are my module definition and it dependencies:

module internal DomainModeling.Domain.PlaceOrderWorkflow.Internal open DomainModeling.Domain.Api open DomainModeling.Domain.Primitives open DomainModeling.Domain.Utils

我想从此模块生成签名文件.但是我对使用dotnet生成器或fsharp编译器感到困惑.如果使用dotnet命令,则无法传递标志-sig 但是如果我使用像这样的fsharp编译器

I want to generate signature file from this module. But I'm confused of using dotnet builder or fsharp compiler. If I use dotnet command I can't pass flag --sig But if I use fsharp compiler like this

fsharpc src/PlaceOrderWorkflow.fs --sig:PlaceOrderWorkflow.fsi

我得到编译器错误.我认为是因为它不了解我的依赖关系.像这样的错误

I get compiler errors. I think because it doesn't know about my dependencies. Errors like this

error FS0039: The namespace or module 'DomainModeling' is not defined.

所以,请告诉我在这种情况下如何生成* .fsi?

So, please, tell me how to generate *.fsi in this case?

推荐答案

您很可能会遇到此错误,因为您没有将所有源文件传递给F#编译器,而只是传递给单个文件.要生成F#接口文件,编译器需要处理整个项目,因此您需要使用所有源文件以及对您所依赖的所有库的引用来调用 fsharpc .如果您的项目不平凡,那可能会很难.

You are most likely getting this error because you did not pass all source files to the F# compiler, but only a single file. To generate F# interface files, the compier needs to process the entire project, so you'd need to call fsharpc with all source files, but also with references to all libraries that you are depending on. If your project is anything non-trivial, this would probably be quite hard.

但是,您可以在普通的 fsproj 项目文件中指定-sig 参数.我刚刚进行了测试,它似乎也可以与.NET Core一起使用.您可以通过添加 OtherFlags 参数来做到这一点:

However, you can specify the --sig parameter in the normal fsproj project file. I just tested this and it seems to work with .NET Core too. You can do this by adding the OtherFlags parameter:

<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp2.2</TargetFramework> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <DefineConstants>TRACE</DefineConstants> <PlatformTarget>AnyCPU</PlatformTarget> <OtherFlags>--sig:test.fsi</OtherFlags> </PropertyGroup> <ItemGroup> <Compile Include="Program.fs" /> </ItemGroup> </Project>

当我指定它并使用 dotnet run 运行我的项目或使用 dotnet build 进行构建时,它将生成带有以下内容的 test.fsi 文件:所有接口.(这是针对整个项目的,但是我认为没有办法将其限制为单个文件的接口.)

When I specify this and run my project using dotnet run or build it using dotnet build, it generates the test.fsi file with all the interfaces. (This is for the whole project, but I don't think there is a way to restrict this to interfaces for a single file.)

更多推荐

如何生成F#签名文件(不使用Visual Studio)

本文发布于:2023-11-15 23:44:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1599025.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   Visual   Studio

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!