简体   繁体   English

Visual Studio F#项目:文件树中的两个文件夹不能同名吗?

[英]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: 在Visual Studio 2013中,我的一个项目包括:

<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: Visual Studio对此嗤之以鼻,声称:

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? 这是VS2013的疏忽,还是我做错了什么?

Unfortunately it's a limitation of F# project system in Visual Studio. 不幸的是,它是Visual Studio中F#项目系统的限制。 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 ). 在即将支持Visual F#Power Tools中的文件夹组织中,我们必须添加验证以防止用户使用菜单项在项目中添加具有重复名称的文件夹(请参阅代码相关讨论 )。 Certainly we can't prevent users doing so by editing fsproj files. 当然,我们无法通过编辑fsproj文件来阻止用户这样做。

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. 也许您可以在microsoft dot com上向fsbugs发送建议,以便可以在即将推出的Visual F#Tools版本中修复它。

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. 假设你依赖于外部库(如引导等- F#是在网上的东西出奇地好,太) 那些组织的文件放到碰巧有重复的文件夹名称文件夹层次结构。

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... 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.): 可以像这样包含在F#项目中(Content标签只是一个例子,它可以是None等):

<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: b ootstrap vs. B ootstrap vs. BO otstrap. 以上示例中的相关位: b oststrap与B ootstrap对比BO otstrap。

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. 我认为它在区分大小写的文件系统上不能很好地工作,除非您同时使用实际的文件夹名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM