如何在Linux上使用fsharp的nuget(How to use nuget with fsharp on Linux)

编程入门 行业动态 更新时间:2024-10-27 16:38:36
如何在Linux上使用fsharp的nuget(How to use nuget with fsharp on Linux)

这是我第一次使用F#在Ubuntu Linux(14.04)上玩它,但我迷失了如何在nuget中包含安装依赖关系。 我有nuget.exe在Mono上正常工作,我可以nuget install包; 他们登陆我的当前目录。 但后来我无法从我的example.fs文件导入或打开它们。 我尝试了各种选择,但无济于事。 我是否需要编写项目文件或使用FAKE? 我找不到任何教程详细介绍了设置简单项目所需的最少必要步骤。

那么我需要做什么来访问我用nuget安装的依赖关系?

It's my first hours with F#, playing with it on Ubuntu Linux (14.04) but I am lost how to include install dependencies with nuget. I have nuget.exe working fine on Mono and i can nuget install packages; they land in my current directory. But then i can't import or open them from my example.fs file. I tried various options but to no avail. Do i need to write a project file or use FAKE? I couldn't find any tutorial which details the minimal necessary steps to setup a simple project.

So what do i need to do to access dependencies i installed with nuget?

最满意答案

简单的答案是它并不完全简单。 漫长的回答是,您可以通过几种不同的方式来解决问题。 我在这里建议的所有方法都使用MSBuild .fsproj项目,以便您可以使用xbuild MyProject.fsproj进行构建。 值得注意的是,FAKE脚本也倾向于使用fsproj项目,并将其交给xbuild进行实际编译。 fsharp.org 网站对引导NuGet配置有一些指导,并且通常是一个很好的资源。

使用MonoDevelop。 我建议从源代码构建。 从https://github.com/mono/monodevelop获取标签,并仔细按照说明操作。 然后安装Nuget插件 。 创建一个F#项目并使用MonoDevelop中的接口将NuGet包添加到您的项目中。 然后您可以从命令行或从MonoDevelop构建。

找到一个使用NuGet的现有项目,将它打开,然后使用您选择的编辑器。 一个重量级的例子是https://github.com/fsprojects/ProjectScaffold ,你可以在那里找到其他人。 一旦你下载了这个项目,你将能够看到如何编辑nuget.config文件来调整你的依赖关系。

最近的项目Paket最终提供了一个真正的命令行方法来解决这个问题。 你再次需要一个.fsproj框架(就像这个例子 ),但是你可以创建一个非常简单的依赖文件。 从Github下载最新版本的Paket。 运行mono paket.exe install将使用此文件从NuGet获取依赖关系,并将它们添加到您的.fsproj作为参考。

有一些引导问题,但是这些方法中的任何一种都会让你超过最初的驼峰。

The short answer is that it is not completely straightforward. The long answer is that you can approach the problem in a few different ways. All the methods I will suggest here use the MSBuild .fsproj projects, so that you can build with xbuild MyProject.fsproj. It's worth noting that FAKE scripts tend to use fsproj projects as well, and hand off to xbuild for the actual compilation. The fsharp.org website has some instructions on bootstrapping NuGet configuration and is a great resource in general.

Use MonoDevelop. I recommend building from source. Get a tag from https://github.com/mono/monodevelop, and follow the instructions carefully. Then install the Nuget plugin. Create an F# project and use the interface in MonoDevelop to add NuGet packages to your project. You can then build from the command line or from MonoDevelop.

Find an existing project that uses NuGet, gut it, and use the editor of your choice. A heavyweight example is https://github.com/fsprojects/ProjectScaffold, you can find others around there. Once you have this project downloaded you will be able to see how to edit the nuget.config file to adjust your dependencies.

A recent project, Paket, offers a truly command-line approach to the problem at last. You again need an .fsproj skeleton (like this example), but you can then create a very simple dependencies file. Download the latest release of Paket from Github. Running mono paket.exe install will then use this file to fetch the dependencies from NuGet and add them to your .fsproj as references.

There is a bit of a bootstrapping problem, but any of these approaches should get you over the initial hump.

更多推荐

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

发布评论

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

>www.elefans.com

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