Gulp script for encrypting DB connection string in web.config after deployment

Hello,

I’m a newbie at gulp. I’m working on a project which has a whole bunch of automated gulp tasks. I didn’t write the scripts for this–some other gulp guru wrote them–but now it has fallen into my hands and I need to modify a few of them.

The one I’m working with now is a script that automates the deployment process. It builds the project and deploys to our test server, then sends out a message to everyone (on Slack) informing them that the latest deploys has been released:

gulp.task(‘deploy-test-web’, [‘build-test-web’], function() {
return gulp.src(’./risk-alive.sln’)
.pipe(plugins.msbuild({
toolsVersion: 14.0,
errorOnFail: true,
stdout: true,
properties: {
Configuration: ‘Test’,
DeployOnBuild: true,
PublishProfile: ‘risk-alive Test.pubxml’
}
}))
.pipe(slack([
{
‘fallback’:
‘Lastest test build is available! <http://acm3/Test/RiskAlive|Click here> to see the awesomeness and to begin your testing!’,
‘pretext’:
‘Lastest test build is available! <http://acm3/Test/RiskAlive|Click here> to see the awesomeness and to begin your testing!’,
‘color’: ‘#D00000’,
‘fields’: [
{
‘title’: ‘Test Build’,
‘value’:
https://... TP for the stories ready for testing’
}
]
}
]));
});

Now what I want to add is an extra step after deployment to encrypt the database connection string in the web.config file. I know I can do this manually from a command prompt after deployment with the following command:

aspnet_regiis -pef “connectionStrings” C:\inetpub\wwwroot[path to web.config]

What I want to know is: is it possible to add this command to the gulp script such that every time we deploy, the database connection string in the web.config gets automatically encrypted? If so, how?

Thanks.