Frage

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?

War es hilfreich?

Lösung

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.

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top