在 ASP.NET Core 的 WebDeploy 期间未找到匹配命令 "dotnet-bundle" 的可执行文件

No executable found matching command "dotnet-bundle" during WebDeploy for ASP.NET Core

我是 ASP.NET 的新手,我正在尝试发布网络应用程序。我尝试使用 2 个不同的主机进行 Web 部署,但一直收到错误消息:-

未找到匹配命令的可执行文件"dotnet-bundle"

这与什么有关?

Project.Json

{
"dependencies": {
"Bitly.Net": "0.0.6",
"BitlyAPI": "1.0.3",
"BundlerMinifier.Core": "2.2.281",
"Common.Logging": "3.4.0-Beta2",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
  "version": "1.0.0-preview2-final",
  "type": "build"
},
"Microsoft.AspNetCore.Routing": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"Parse": "1.7.0",
"Spring.Social.Twitter": "2.0.0-M1",
"Stormpath.AspNetCore": "0.7.0"
},

"tools": {
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},

"frameworks": {
"net46": {
  "frameworkAssemblies": {
  }
}
},

"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},

"publishOptions": {
"include": [
  "wwwroot",
  "**/*.cshtml",
  "appsettings.json",
  "web.config"
]
},

"scripts": {
"prepublish": [ "bower install", "dotnet bundle" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
},
"userSecretsId": "aspnet-ParseAppDashboard-20161008081***"
}

工具部分Project.json添加这个-

  "tools": {
    "BundlerMinifier.Core": "2.2.281",
    ....

保存后 Project.json,VS2015 自动恢复包。

如果它不起作用,请右键单击项目并单击“还原包”选项。

如果这不起作用,请尝试使用 dotnet restore CLI 命令恢复。

看看这是否有帮助。

自 2016 年底(RC3 及更高版本、VS2017 及更高版本)移至 .csproj 文件格式,添加

<DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.6.375" />

<ItemGroup>:

<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">

  ...

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0-msbuild3-final" />
    <DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.6.375" />
  </ItemGroup>
</Project>

或者为您的 DotNetCliToolReference 设置创建一个新的 <ItemGroup>(您可以有很多)。

但是查看https://www.nuget.org/packages/BundlerMinifier.Core最新版本号

您可能还需要添加

"runtimes": {
"win10-x64": {}
},

如果您想升级到核心 1.1(也更改为在 global.json 文件中更正运行时)到您的 project.json到 VS2015 中的 1.1。