8

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?

gregoryp
  • 920
  • 4
  • 15
  • 35

2 Answers2

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.

Allan Nielsen
  • 260
  • 2
  • 13
  • 1
    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? – padigan Jul 31 '17 at 11:30
  • 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. – Allan Nielsen Sep 14 '17 at 02:15
  • tried everything still getting error while publishing , any other solution ? – Neo Oct 11 '18 at 12:17
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
isanka thalagala
  • 456
  • 2
  • 10
  • 22