【问题标题】:Visual Studio F# project: Can't have two folders in a file tree with the same name?Visual Studio F# 项目:文件树中不能有两个同名的文件夹?
【发布时间】:2015-03-11 15:15:29
【问题描述】:

在 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 对此感到窒息,声称:

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'.

如果我像这样更改包含,一切都很好:

<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>

这是 VS2013 中的疏忽,还是我做错了什么?

【问题讨论】:

    标签: f# visual-studio-2013 project


    【解决方案1】:

    不幸的是,这是 Visual Studio 中 F# 项目系统的限制。更详细的分析可以在this article找到。

    在即将在Visual F# Power Tools 中对文件夹组织的支持中,我们必须添加验证以防止用户使用菜单项在项目中添加具有重复名称的文件夹(请参阅the coderelevant discussion)。当然,我们不能通过编辑fsproj 文件来阻止用户这样做。

    也许您可以向 microsoft dot com 的 fsbugs 发送建议,以便在即将发布的 Visual F# Tools 版本中修复它。

    【讨论】:

      【解决方案2】:

      这是我目前用来解决此限制的方法:

      假设您依赖外部库(例如 Bootstrap 等 - F# 也非常擅长网络内容),确实将它们的文件组织到恰好具有重复文件夹名称的文件夹层次结构中。

      如果您更改同名文件夹的大小写,您可以保留该文件夹结构。 例如,这是可行的(如果文件夹名称允许足够的大写组合,您可以扩展此模式)

      以下文件夹结构:

      字体\引导程序... 样式表\引导程序... javascripts\bootstrap...

      可以像这样包含在 F# 项目中(Content 标签只是一个例子,它可以是 None 等):

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

      ...等等。

      上述示例中的相关位:bootstrap vs. Bootstrap vs. BOotstrap。

      之后一切正常。我想它在区分大小写的文件系统上效果不佳,除非您也使用实际的文件夹名称。

      【讨论】:

        猜你喜欢
        • 2010-10-13
        • 2012-12-31
        • 2011-02-06
        • 2019-02-09
        • 1970-01-01
        • 2019-10-08
        • 2010-10-19
        • 2020-05-02
        • 1970-01-01
        相关资源
        最近更新 更多