6

I have a simple web project with a bower.json, package.json and a Gruntfile.js I have modified my .csproj file to add targets to run

  1. npm install
  2. bower install
  3. grunt build

npm install runs fine but it fails to run bower install. This is all that I have from the logs

node_modules\.bin\bower cache clean
node_modules\.bin\bower install

C:\a\src\TestProj\TestProj\TestProj.csproj(137,5): error MSB3073: The command ".\node_modules\.bin\bower install" exited with code 1.

Here is what I am doing in the csproj definitio

<Target Name="BeforeBuild">
    <Exec Command="npm cache clean" />
    <Exec Command="npm install" />
    <Exec Command="node_modules\.bin\bower cache clean" />
    <Exec Command="node_modules\.bin\bower install" />
</Target>

Here is my bower.json

 "name": "TestProj",
 "version": "0.0.1",
 "description": "",
 "main": "index.html",
 "moduleType": [
   "amd"
 ],
 "authors": [
   "Sujesh Arukil"
 ],
 "license": "MIT",
 "private": true,
 "ignore": [
   "**/.*",
   "node_modules",
   "bower_components",
   "test",
   "tests"
 ],
 "devDependencies": {
   "knockoutjs": "~3.2.0"
 }
Sujesh Arukil
  • 2,469
  • 16
  • 37

5 Answers5

2

I was able to hack past this issue by commenting out the bower install command in the .csproj file

  <Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
    <!--<Exec Command="bower install" />-->
    <Exec Command="dotnet bundle" />
  </Target>
Derrick
  • 2,502
  • 2
  • 24
  • 34
1

the bower install was failing because two modules that I was intalling depended on different versions of jQuery and could not find a resolution and wanted user input. Fixed it by providing a resolution section.

Sujesh Arukil
  • 2,469
  • 16
  • 37
0

First, enable diagnostic logging.

Then modify your target:

<Target Name="BeforeBuild">
    <Exec Command="npm cache clean" />
    <Exec Command="npm install" />
    <Message Condition="!EXISTS('node_modules\.bin\bower')" Text="bower does not exist" Importance="high" />
    <Exec Command="node_modules\.bin\bower cache clean" />
    <Exec Command="node_modules\.bin\bower install" />
</Target>
Nicodemeus
  • 4,005
  • 20
  • 23
0

You should be able to download an additional MSBuild Log file that may have more detail in it. If you view your previously failed build than click the "View Log" link at the top, then look in the details and you should see a link for the log file a couple of lines past your error message.Build Error

If I had to guess off the top of my head though you are getting that error because git is not available.

Kent Cooper
  • 4,319
  • 3
  • 19
  • 23
  • I am trying to get this working from a PowerShell script. npm install works fine when the script tries to run bower install it fails with Error: git is not installed or not in the PATH – David Paquette Feb 19 '15 at 02:39
  • Not sure if it will help with from a PowerShell script, but I use [NoGit](http://www.nuget.org/packages/NoGit/) from my msbuild script. – Kent Cooper Feb 19 '15 at 03:35
  • 1
    I added NoGit to my packages.json but that did not help. I am getting the same error. – David Paquette Feb 19 '15 at 18:55
0

Worked for me by removing the code below in the .csproj file.

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

However it did cause a couple of typescript issues with duplicate method names, add the below code to the tsconfig.json file

"exclude": [ "obj" ]

Ryan Gavin
  • 689
  • 1
  • 8
  • 22