Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core 捆扎机及;迷你发电机;对象引用未设置为对象的实例;错误_Asp.net Core_Asp.net Core 3.0 - Fatal编程技术网

Asp.net core 捆扎机及;迷你发电机;对象引用未设置为对象的实例;错误

Asp.net core 捆扎机及;迷你发电机;对象引用未设置为对象的实例;错误,asp.net-core,asp.net-core-3.0,Asp.net Core,Asp.net Core 3.0,我正在尝试使用buildBundlerMinizier.Core在ASP.NET Core 3.0中捆绑和缩小CSS和JS文件。 还为Visual Studio 2019安装了Bundler&Minifier扩展 当我尝试调试项目时,它正常工作,没有错误,但当我重新构建它时,我得到以下错误 对象引用未设置为对象的实例 我在重新启动Visual Studio时没有收到错误,我可以再次调试项目,但如果我再次重建它,我会收到错误 它是bundleconfig.json文件 [ { "ou

我正在尝试使用
buildBundlerMinizier.Core
在ASP.NET Core 3.0中捆绑和缩小CSS和JS文件。 还为Visual Studio 2019安装了
Bundler&Minifier
扩展

当我尝试调试项目时,它正常工作,没有错误,但当我重新构建它时,我得到以下错误

对象引用未设置为对象的实例

我在重新启动Visual Studio时没有收到错误,我可以再次调试项目,但如果我再次重建它,我会收到错误

它是
bundleconfig.json
文件

[
  {
    "outputFileName": "wwwroot/assets/css/style.bundle.min.css",
    "inputFiles": [
      "wwwroot/assets/plugins/global/plugins.bundle.css",
      "wwwroot/assets/css/style.bundle.css",
      "wwwroot/assets/css/skins/header/base/light.css",
      "wwwroot/assets/css/skins/header/menu/light.css",
      "wwwroot/assets/css/skins/brand/light.css"
    ],
    "sourceMap": false,
    "sourceMapRootPath": null
  }
,
{
  "outputFileName": "wwwroot/assets/js/scripts.min.js",
  "inputFiles": [
    "wwwroot/assets/plugins/global/plugins.bundle.js",
    "wwwroot/assets/js/scripts.js",
    "wwwroot/assets/js/pages/dashboard.js",
    "wwwroot/content/js/mobil-detect.js",
    "wwwroot/content/js/lazy-img.js",
    "wwwroot/content/js/ziyaretci.js"
  ]
}
]

Visual Studio、Bundler&Minifier扩展、BuildBundlerMinifier和BuildBundlerMinifier.Core都是最新的
如何修复它?

该项目有BuildBundlerMinifier和BuildBundlerMinifier.Core。我从nuget中删除了BuildbunderMinifier,现在它可以工作了。

如果您(像我一样)在目录名的某个地方有一个散列(#),那么使用BuildbunderMinifier的.NET Core 3.1将破坏精简

我花了一些时间才弄明白这一点,包括卸载和重新安装nuget软件包和Visual Studio扩展

我想知道是否还有其他特殊角色导致了这个问题

您可以在bundleconfig.json中轻松看到这一点

文件夹结构示例:

C:\MyProjects\C#Test\MySolution\MyProject\wwwroot\js\
如果损坏,它将看起来像:

[
  {
    "outputFileName": "#Test\\MySolution\\MyProject\\wwwroot\\js\\Math.min.js",
    "inputFiles": [
      "#Test\\MySolution\\MyProject\\wwwroot\\js\\Math.js"
    ]
  }
]
而不是

[
  {
    "outputFileName": "wwwroot/js/Math.min.js",
    "inputFiles": [
      "wwwroot/js/Math.js"
    ]
  }
]

这可能是一个js文件源中的语法问题。 在我的例子中,使用空聚结操作符“?”是个问题。
将其替换为简单的“if”null检查,编译错误消失。

sourceMapRootPath
设置为null。也许这是导致工具出错的原因?我删除了sourceMapRootPath。它有时可以建立,有时返回错误。我不明白@OliverAll输入文件在目录中?输入文件是静态的,即它们是生成的还是始终存在?是的,所有输入文件都在目录和静态文件中@OliverGot bundler nuget软件包的最新版本?那么您是如何在构建或文件更改时绑定的?