The command "dotnet bundle" exited with code 1 - VS 2017 Publish ASP.NET Core Web API
Asked Answered
G

2

9

I'm getting the following error when trying to publish my Web API to a server:

The command "dotnet bundle" exited with code 1

This is the publish screen: enter image description here

This is the error from output:

enter image description here

Can anyone help me?

Grizzle answered 27/4, 2017 at 10:57 Comment(2)
The tool might not be installed? BundlerMinifier wikiUgo
Yes, it's installed.Grizzle
L
13

Make sure you have added the DotNetCliToolReference in your WebApi project. I'm assuming VS2017 csproj file.

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
    <DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.2.281" />
  </ItemGroup>

The second entry in the code above.

Littlest answered 7/6, 2017 at 3:33 Comment(3)
I migrated a solution from VS2015 to VS2017 and I have the same problem, unfortunately this fix didn't work for me. I can run 'dotnet bundle' command from any other folders apart from any of the project folders in the migrated solution!?! Its like its being blocked somehow but can't figure out anywhere that could be blocking it. Don't suppose you've any other suggestions?Dessiedessma
Try creating a new project using vs2017 of the same type you are having issues with. Then compare the project files for the differences, updating the original with missing/changed values.Littlest
tried everything still getting error while publishing , any other solution ?Monopteros
P
6

Method 01

Find your .csproj file and right_click > Edit or right click on you project go to 'Edit projectnam.csproj'

Then comment or remove

  <Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
    <Exec Command="bower install" />
    <Exec Command="dotnet bundle" />
</Target>

Method 02

You need install NodeJS globally. then run

npm install -g bower 

and

npm install -g gulp
Pliant answered 29/1, 2018 at 7:57 Comment(3)
tried everything still getting error while publishingMonopteros
Upgraded my web app to .NET Core 2.2 and your first method worked like a charm. Thank you very much.Grizzle
Error says that there is something wrong with dotnet bundle, so there is no need to install NodeJs or install bower to resolve dotnet related error.Breath

© 2022 - 2024 — McMap. All rights reserved.