Skip to content

Instantly share code, notes, and snippets.

@icardosos
Last active June 5, 2018 12:41
Show Gist options
  • Save icardosos/00dc300667240a66e83fe5d0a1c46653 to your computer and use it in GitHub Desktop.
Save icardosos/00dc300667240a66e83fe5d0a1c46653 to your computer and use it in GitHub Desktop.
Script to publish asp.net core apps on AWS Elastic Beanstalk
<Target Name="MyPostCompileTarget" AfterTargets="AfterPublish">
<Exec Command="gulp aws:prepareoutput" />
<Exec Command="gulp aws:zip:package" />
<Exec Command="gulp aws:postpackage:clean" />
<Exec Command="gulp clean:aws:publish" />
</Target>
{
"manifestVersion": 1,
"deployments": {
"aspNetCoreWeb": [
{
"name": "api-core",
"parameters": {
"appBundle": "webapp.zip",
"iisPath": "/",
"iisWebSite": "Default Web Site"
}
}
]
}
}
"use strict";
var gulp = require("gulp"),
rimraf = require("rimraf"),
clean = require("gulp-rimraf"),
zip = require("gulp-zip");
var webroot = "./wwwroot/";
var AWS = "./AWS/";
var paths = {
publish: AWS + "publish/",
output: AWS + "output/"
};
gulp.task("clean:aws:publish", function (cb) {
rimraf(paths.publish, cb);
});
gulp.task("aws:clean:publish", function () {
return gulp.src(paths.publish + "*", { read: false }).pipe(clean());
});
gulp.task("aws:clean:output", function () {
return gulp.src(paths.output + "*", { read: false }).pipe(clean());
});
gulp.task("aws:clean", ["aws:clean:publish", "aws:clean:output"]);
gulp.task("aws:postpackage:clean", function () {
gulp.src(paths.output + "aws-windows-deployment-manifest.json", { read: false }).pipe(clean());
gulp.src(paths.output + "webapp.zip", { read: false }).pipe(clean());
});
//zip
gulp.task("aws:zip:publish", function () {
return gulp.src(paths.publish + "**")
.pipe(zip("webapp.zip"))
.pipe(gulp.dest(paths.output));
});
gulp.task("aws:copymanifest", function () {
return gulp.src(AWS + "aws-windows-deployment-manifest.json")
.pipe(gulp.dest(paths.output));
});
gulp.task("aws:prepareoutput", ["aws:zip:publish", "aws:copymanifest"]);
var date = new Date();
var dateFormat = date.toJSON().replace(/:/g, '-');
var pjson = require('./package.json');
gulp.task("aws:zip:package", function () {
return gulp.src(paths.output + "*")
.pipe(zip(pjson.version + "_" + dateFormat + ".zip"))
.pipe(gulp.dest(paths.output));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment