You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ASP.NET Core Razor Pages执行dotnet bundle提示找不到命令求助

ASP.NET Core Razor Pages中执行dotnet bundle提示"No executable found matching command 'dotnet-bundle'"

我是ASP.NET Core的新手,最近想在Razor Pages项目中实现CSS/JS的压缩功能,查资料了解到BundlerMinifier工具,但遇到了棘手的问题:

我用VS2017通过.NET Core/ASP.NET Core Web Application/"Web Application"创建了基础的Razor Pages项目,只修改了site.css来测试压缩效果。已经通过NuGet包管理器确认安装了BundlerMinifier.Core v2.6.362,我的.csproj文件内容如下:

<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="BundlerMinifier.Core" Version="2.6.362" />
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.1" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.1" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.6.362" />
  </ItemGroup>
</Project>

项目已经保存并生成成功,但在包管理器控制台执行dotnet bundle命令时,却收到了如下错误:

PM> dotnet bundle
dotnet : No executable found matching command "dotnet-bundle"
At line:1 char:1
+ dotnet bundle
+ ~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (No executable f..."dotnet-bundle":String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
PM>

我已经尝试了针对.csproj的相关解决方案,但都没解决问题。因为是新手没法直接评论原答案,所以只好发新帖求助。

我只是想在项目中引入自定义CSS和JS,听说用BundlerMinifier是标准做法,有没有更简单的方案?而且我很疑惑,面向新手的默认模板为什么不自带这个功能呢?实在不知道问题出在哪了,求各位大佬帮忙!

内容的提问来源于stack exchange,提问作者user9158760

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:26:35