Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio F# project: Can't have two folders in a file tree with the same name?

In Visual Studio 2013, one of my projects includes:

<ItemGroup>
    <Compile Include="Entity\Abstract\Entity.fs" />
    <Compile Include="Entity\HumanEntity.fs" />
    <Compile Include="State\Abstract\State.fs" />
    <Compile Include="State\Abstract\HumanState.fs" />
    <Compile Include="State\Human\HumanIdleState.fs" />
    <Compile Include="State\Human\HumanAwakenState.fs" />
</ItemGroup>

Visual Studio chokes on this, claiming that:

The project 'Entity.fsproj' could not be opened because opening it would cause a folder to be rendered multiple times in the solution explorer. One such problematic item is 'State\Abstract\State.fs'.

If I change the includes like so, everything is fine:

<ItemGroup>
    <Compile Include="Entity\AbstractEntity\Entity.fs" />
    <Compile Include="Entity\HumanEntity.fs" />
    <Compile Include="State\AbstractState\State.fs" />
    <Compile Include="State\AbstractState\HumanState.fs" />
    <Compile Include="State\Human\HumanIdleState.fs" />
    <Compile Include="State\Human\HumanAwakenState.fs" />
</ItemGroup>

Is this an oversight in VS2013, or am I doing something wrong, here?

like image 549
MiloDC Avatar asked Apr 03 '14 17:04

MiloDC


People also ask

What is F# in Visual Studio?

F# is a universal programming language for writing succinct, robust and performant code.

Is Visual Studio 2022 free?

Visual Studio Community 2022A free, fully featured, and extensible solution for individual developers to create applications for Android, iOS, Windows, and the web.

Is Microsoft Visual Studio free?

Visual Studio Community. A fully-featured, extensible, free IDE for creating modern applications for Android, iOS, Windows, as well as web applications and cloud services.

What is Visual Studio used for?

Description: Microsoft Visual Studio is an integrated development environment (IDE) used to develop console and graphical user interface applications along with Windows Forms applications, ASP.NET applications, web sites, web applications, and web services using native code and managed code.


2 Answers

Unfortunately it's a limitation of F# project system in Visual Studio. A more detailed analysis could be found in this article.

In the upcoming support for folder organization in Visual F# Power Tools, we have to add validation to prevent users from adding folders with duplicated name in a project using menu items (see the code and relevant discussion). Certainly we can't prevent users doing so by editing fsproj files.

Perhaps you can send a suggestion to fsbugs at microsoft dot com, so that it could be fixed in an upcoming version of Visual F# Tools.

like image 80
pad Avatar answered Oct 20 '22 16:10

pad


Here's what I'm currently using to work around this limitation:

Say you depend on external libraries (such as Bootstrap, etc. - F# is surprisingly good at web stuff, too) that do organize their files into folder hierarchies that happen to have duplicate folder names.

You can preserve that folder structure if you change the capitalization of folders that have the same name. For example, this works (and you can extend this pattern, should the folder name allow for sufficient capitalization combinations)

The following folder structure:

fonts\bootstrap... stylesheets\bootstrap... javascripts\bootstrap...

Can be included in an F# project like so (the Content tag is just an example, it can be None , etc.):

<Content Include="fonts\bootstrap\glyphicons-halflings-regular.eot" />
...
<Content Include="javascripts\Bootstrap\affix.js" />
...
<Content Include="stylesheets\BOotstrap\_alerts.scss" />
...

...and so on.

The relevant bit in the above sample: bootstrap vs. Bootstrap vs. BOotstrap.

Everything works after that. I suppose it doesn't work well on case-sensitive file systems unless you muck with actual folder names as well.

like image 40
ca-ta Avatar answered Oct 20 '22 16:10

ca-ta