Sneak peeks into the F# project system, part three
Posted by Brian on August 3, 2008
There will be a number of new F# IDE features in the upcoming CTP release. One that you may have used with other Visual Studio languages is "Add As Link".
Add As Link
By default, when you add an existing item that lives outside of the current project directory, Visual Studio will copy the file to the current project directory.
If I select a file from some other directory (for instance, from a C# project directory)…
Then a copy of that file (here, App.config) gets added to the project:
You can tell it’s a copy by looking on disk:
which shows the new file has been copied to the F# project directory:
However, if we start over, we could instead choose to add the file as a link (notice the drop-down in the bottom-right corner of the screenshot):
Then a linked file is added to the project:
Note the little arrow sub-glyph in the icon that shows that the file is a link. It has not been copied to the project directory:
If you are familiar with msbuild, then you may recognize the representation in the .fsproj project file:
Whereas the "Include=" bit describes the physical location of the file, the optional "<Link>" tag is used by linked items to describe how to project linked files into the solution explorer view inside Visual Studio. This is no different than how things work in C#.
Also in the upcoming CTP release, we’ll also support a better "ordering experience" from inside the solution explorer in the IDE.
Move Up and Move Down
If you want to change the ordering of files, you can do it via the right-click menu in the solution explorer. Say I have
and I decide that Program.fs needs to be moved before File2.fs. I can right click on Program.fs…
and select "Move Up", and…
now Program appears above File2. There will be a key-binding (probably Alt-Up/Alt-Down) associated with the Move Up and Move Down commands.
Add Above and Add Below
If I am adding a new file to a project, and I want it to appear in the ‘middle’ somewhere, I could right-click on the project, do "Add New Item…", have the item get added to the bottom, and then use a series of Move Up commands to get the file into the right spot. Or, I could use this new menu command:
so that the new file appears above or below an existing item. Here I’ve added a new item File3.fs above Program.fs:
These new commands make it much easier to manage the file order in an F# project.