F# project templates

171 views
Skip to first unread message

Robin Neatherway

unread,
Apr 25, 2015, 10:41:35 AM4/25/15
to fsharp-o...@googlegroups.com
I'm planning to add support for project creation in Emacs, and
hopefully other editors, possibly by making the creation support part
of FSharp.AutoComplete. I've been looking around for canonical project
files to use a starting point, and I'm not quite sure what the best
would be.

A few options are:

1. https://github.com/fsprojects/FSharpCommunityTemplates
2. https://github.com/fsprojects/ProjectScaffold
3. Create a project in VS or XS and use that as a starting point

The best so far seems to be the ProjectScaffold, which includes FAKE
and Paket, making working from the command line much easier. As it
includes an init script, the Emacs support could be as simple as
offering a function to clone the repo and kick off the init script. On
the downside, all these different components (including SourceLink and
FSharp.Formatting) could be daunting for someone new to the language
compared to just creating MyProject.fsproj and Program.fs to get
started.

I'd be interested to hear any suggestions.

Cheers,
Robin

Tomas Petricek (Info)

unread,
Apr 25, 2015, 12:19:26 PM4/25/15
to fsharp-o...@googlegroups.com
I wanted to create easy to use cross-platform templates for FsLab (data science) projects and I ended up with just a GitHub repo that has one branch for each template. The way to use it is to download the ZIP and rename your project:
https://github.com/fslaborg/FsLab.Templates (a fairly low-tech solution, but it seems to be simple to manage & easy to use).

The basic template is very minimalistic. The journal one comes with "build.sh" and "build.cmd" to run it (I think I might add the build commands to the basic one too, but just to restore Paket packages).

There is an interesting customization in the "fsproj" file so that it runs "paket install" the first time you use it (this way, you get latest versions of all packages and we do not have to change the template all the time) and if "paket.lock" exists, it runs just "paket restore". (In basic template, this is in separate *.targets file, in the journal template, this is directly in the *.fsproj file - though this is just for compatibility with another VS template).

I think a VS/XS project + added Paket is a reasonable starting point for small things. ProjectScaffold is great for starting open source projects.

T.
--
--
To post, send email to fsharp-o...@googlegroups.com
To unsubscribe, send email to
fsharp-opensou...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/fsharp-opensource
---
You received this message because you are subscribed to the Google Groups "F# Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fsharp-opensou...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Colin Bull

unread,
Apr 26, 2015, 11:21:08 AM4/26/15
to fsharp-o...@googlegroups.com
Simon Cousins was playing with this I'm not sure how far he got but it is here https://github.com/simontcousins/fsproj-mode. If your interested. 

Additionally, I think the approach the projectile project takes is an interesting one (https://github.com/bbatsov/projectile) as this is very generic. However it doesn't tackle the problem of keeping sln and fsproj  files up-to-date. 

P.S. I would love to see this and have been thinking about it for ages - but I'm having trouble recently focusing my efforts on just one thing. But I'd be glad to help in anyway, with a project like this. 

Karl Nilsson

unread,
Apr 27, 2015, 4:30:53 AM4/27/15
to fsharp-o...@googlegroups.com
I'd be quite happy, as a start, if fsharpautocomplete had a command with project type (dll, exe) and and project name parameters that could return the .fsproj file xml output. Everything else is fairly straight forward to create manually as you need it. 

Are you thinking of adding functionality such as 'add project reference' and 'add file to project'?

--

Robin Neatherway

unread,
Apr 27, 2015, 12:13:52 PM4/27/15
to fsharp-o...@googlegroups.com
Thanks for the various suggestions.

> There is an interesting customization in the "fsproj" file so that it
> runs "paket install" the first time you use it (this way, you get
> latest versions of all packages and we do not have to change the
> template all the time) and if "paket.lock" exists, it runs just "paket
> restore". (In basic template, this is in separate *.targets file, in
> the journal template, this is directly in the *.fsproj file - though
> this is just for compatibility with another VS template).

This is something I would definitely like to make available as an
option. This kind of neat integration with Paket can make a big
difference I think.

Regarding the zips, do you make them available from inside an editor,
or just point people to the relevant location? I would really prefer
to do the former.

> On Sun, 26 Apr 2015 at 16:21 Colin Bull <coli...@gmail.com> wrote:
>> Simon Cousins was playing with this I'm not sure how far he got but it is
>> here https://github.com/simontcousins/fsproj-mode. If your interested.

This is very interesting! I have been thinking about doing something
like this myself. I would like to bundle this up with fsharp-mode.
However, I don't think it lets you get started from nothing.

>> Additionally, I think the approach the projectile project takes is an
>> interesting one (https://github.com/bbatsov/projectile) as this is very
>> generic.

I use projectile, but I think it is a bit too generic for this.

On Mon, Apr 27, 2015 at 9:30 AM, Karl Nilsson <kjni...@gmail.com> wrote:
> I'd be quite happy, as a start, if fsharpautocomplete had a command with
> project type (dll, exe) and and project name parameters that could return
> the .fsproj file xml output. Everything else is fairly straight forward to
> create manually as you need it.
>
> Are you thinking of adding functionality such as 'add project reference' and
> 'add file to project'?

This was what I thought I would start with, yes. Adding a project
reference is less obvious to do manually as there isn't something to
copy, so that would probably be useful. If the commands get very
complicated we might want to start sending JSON in both directions
though.

Do you have any opinion about Paket/FAKE scripts? I think the former
could be especially useful for helping people to get started using
NuGet packages.

don...@fastmail.fm

unread,
Apr 28, 2015, 8:10:54 AM4/28/15
to fsharp-o...@googlegroups.com
Hi Robin,

Great to hear about this. Adding it to fsautocomplete.exe could be a
really useful route to disseminate this to all editors.

I'm not sure it helps but there's a semi-canonical set of project files
made by various templates in Visual Studio versions over the years here:

https://github.com/fsharp/fsharp/tree/master/tests/projects

Cheers!
Don

> .... project templates in Emacs ....



Tomas Petricek (Info)

unread,
Apr 28, 2015, 9:03:54 AM4/28/15
to fsharp-o...@googlegroups.com
>> Regarding the zips, do you make them available from inside an editor, or just
>> point people to the relevant location? I would really prefer to do the former.

At the moment, those are just available for download on the web site (so that we are not telling people which editor they should use). I think having an editor command that unpacks the ZIP and perhaps does some renaming & replacements would be nice - but I fear it is harder to maintain templates in that way (we have those ZIPs and also FsLab template for VS, which is more painful :)).

T.

-----Original Message-----
From: fsharp-o...@googlegroups.com [mailto:fsharp-o...@googlegroups.com] On Behalf Of Robin Neatherway

Robin Neatherway

unread,
May 1, 2015, 11:53:55 AM5/1/15
to fsharp-o...@googlegroups.com
OK, I think I will just use the project files from
github.com/fsharp/fsharp for the moment. However, I have a little
stumbling block: what is the best way to make these text files
available to an F# program at runtime? I have read a bit about
resources, which seem mainly targeted at things like icons, and I have
never used, but the instructions all include using Visual Studio to
perform some "add resource" action in the GUI. Is there a simpler way,
or a an example project file on the web I could adapt?

Karl Nilsson

unread,
May 9, 2015, 5:45:57 AM5/9/15
to fsharp-o...@googlegroups.com
How are you getting on with this Robin? Having had a think about it I would love to see project/solution functionality as a separate, command line utility (or even just a set of fsx scripts), similar to something like paket rather than baked into fsac. What do you think?

Cheers
Karl

Robin Neatherway

unread,
May 9, 2015, 6:33:23 AM5/9/15
to fsharp-o...@googlegroups.com

Hi Karl,

I've only had time to make a very basic start, so nothing to show really. The idea of having it as a separate tool sounds quite workable, and would make it simple to integrate with. Fsx scripts take a few seconds to load because of JITing the whole compiler assembly so I think a single exe would be better.

One disadvantage of moving it out would be to do with reloading the project in fsac. If you want to add a file or reorder the files, if fsac was doing it then it could immediately also reload the project. As an external tool the editor would need to then additionally tell fsac to do that.

Let's consider one use case: reordering files. Would you make one call to request the current files and another to say move a particular file up? Or use the list of files that fsac gives you when you load a project as a starting point?

If you'd like to do it as an external tool I would be happy to work with you on it. Let's make a repo under fsprojects.

Robin

Karl Nilsson

unread,
May 10, 2015, 3:38:24 AM5/10/15
to fsharp-o...@googlegroups.com
It would probably be beneficial to work out what operations we'd like to support and roughly what kind of command line protocol would be suitable. For moving a file there are options - one would be to just specify the file you want to move and the file you want to move above but let's see what falls out. 

I think at a first stab it would be good to support:
- create new project (exe, dll)
- add / remove project to solution file
- add / remove project reference
- add / remove file from project
- re-order file

Anything obvious I've missed?

Robin Neatherway

unread,
May 10, 2015, 11:58:16 AM5/10/15
to fsharp-o...@googlegroups.com
I agree that would cover most use cases. When generating we should be
able to configure the name I suppose, and possibly set the
TargetFramework and TargetFSharpCoreVersion, although those are all
easily modified by editing the file by hand. For re-order, up/down by
N might be enough.
Reply all
Reply to author
Forward
0 new messages