Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to build and package my project using Azure's Git deployment.

I have created the following files

  • .deployment
  • deploy.cmd
  • Gruntfile.js
  • package.json

My .deployment file calls deploy.cmd. deploy.cmd sets up the environment by setting the path to include a checked in copy of Node.js and npm. I can call npm install just fine. When I call grunt, it seems to execute up to the first standard out message, then it returns and the error return code is set. I don't get any other message than that. Other commands seem to run just fine.

I've tried piping out the STDERR, no luck. I tried running under the Remote Execution console, no luck there. My Gruntfile.js runs locally just fine.

Is there some magic sauce that I am missing?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
500 views
Welcome To Ask or Share your Answers For Others

1 Answer

This is a bit old, but I will answer it anyway just in case someone comes across this question.


First, it is helpful to run grunt with colors disabled, as both the diagnostic console and the deployment logs struggle with the ANSI codes. To do this, run grunt --no-color. This should get the STDOUT information back into the Console and into the Deploy log.

Second, I do not recommend using checked-in versions of Node or NPM. Windows Azure already has these build in to the environment, and already is configured for the special temporary paths and cache paths needed for both to execute at their best.

Project Kudu is the deployment engine powering Azure Deployments, but you already know this, since you have a .deployment file. However, the Azure Command Line Tools [npm install azure-cli --global] will help you scaffold out some better deployment scripts that will use Azure's pre-installed Node and NPM setup.

azure site deploymentscript –-node

will get you that base node script.

From there, a few modifications are needed to deploy.sh to get it to execute Grunt, reliably. Within deploy.sh is a #Deployment section. Replace its contents with the following:

# Deployment
# ----------

echo Handling node.js grunt deployment.

# 1. Select node version
selectNodeVersion

# 2. Install npm packages
if [ -e "$DEPLOYMENT_SOURCE/package.json" ]; then
  eval $NPM_CMD install
  exitWithMessageOnError "npm failed"
fi

# 3. Install bower packages
if [ -e "$DEPLOYMENT_SOURCE/bower.json" ]; then
  eval $NPM_CMD install bower
  exitWithMessageOnError "installing bower failed"
  ./node_modules/.bin/bower install
  exitWithMessageOnError "bower failed"
fi

# 4. Run grunt
if [ -e "$DEPLOYMENT_SOURCE/Gruntfile.js" ]; then
  eval $NPM_CMD install grunt-cli
  exitWithMessageOnError "installing grunt failed"
  ./node_modules/.bin/grunt --no-color clean common dist
  exitWithMessageOnError "grunt failed"
fi

# 5. KuduSync to Target
"$KUDU_SYNC_CMD" -v 500 -f "$DEPLOYMENT_SOURCE/dist" -t "$DEPLOYMENT_TARGET" -n "$NEXT_MANIFEST_PATH" -p "$PREVIOUS_MANIFEST_PATH" -i ".git;.hg;.deployment;deploy.sh"
exitWithMessageOnError "Kudu Sync to Target failed"

This will run npm install, followed by bower install (if bower.json exists), followed by grunt clean common dist (if Gruntfile.js exists), and finally a KuduSync into your /wwwroot. (Note: replace 'clean common dist' with whatever Grunt tasks you need to run.)

There are a few other issues you may run in to. I write this up in a post on my personal blog, which includes some of the issues you may run into.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...