【问题标题】:asp.net core exclude files from the buildasp.net 核心从构建中排除文件
【发布时间】:2016-10-08 05:59:54
【问题描述】:

我正在尝试将 Protractor 添加到我的 asp.net-core 应用程序中。

我通过 npm 添加了它,它安装了 selenium-webdriver,其中包含一个文件 Page.aspx.cs。这会导致构建错误,但我的项目甚至不需要编译它。

所以我正在尝试使用 project.json 排除 node_modules

"buildOptions": {
  "emitEntryPoint": true,
  "preserveCompilationContext": true,
  "compile": {
    "excludeFiles": "node_modules"
  }
},

Illegal characters in path 一样:

 "excludeFiles": ["node_modules"]

这似乎与 _ 字符有关,但我不知道为什么会出现问题。

谢谢

【问题讨论】:

    标签: c# asp.net-core


    【解决方案1】:

    我设法使用exclude 而不是excludeFiles 来完成这项工作

    "buildOptions": {
      "emitEntryPoint": true,
      "preserveCompilationContext": true,
      "compile": {
        "exclude": ["node_modules"]
      }
    },
    

    【讨论】:

      【解决方案2】:

      您是否尝试使用特定文件名而不是文件夹名?

      "excludeFiles": ["node_modules/path/to/Page.aspx.cs"]
      

      【讨论】:

        【解决方案3】:

        Solution - 在 Solution Explorer 中,右键单击 node_modules 文件夹,然后单击 "从项目中排除”

        原因 - 如果您在 Visual Studio 中使用网站项目时正在开发包含大量依赖项的 npm 和 node_module 文件夹的客户端应用程序,这是一个糟糕的解决方案。它会导致非常加载时间慢和/或文件加载错误。

        如果您的项目中有 node_modules 文件夹,它将影响项目中的文件以及发布。最后,在你的项目中使用 node_modules 巨大的文件夹没有办法限制文件或文件夹并最终给出错误。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-06-15
          • 1970-01-01
          • 2017-08-05
          • 2020-01-03
          • 2014-07-23
          • 2014-10-05
          相关资源
          最近更新 更多