Previous versions of ASP.NET allowed you to auto-increment the version number via Project Properties. How can I do this in MVC 6?
MVC 6 now uses project.json to track version and you can bump this number using gulp-bump.
Add gulp-bump to package.json > devDependencies
gulp-bump": "1.0.0"
Edit gulpfile.js
bump = require("gulp-bump") to the dependencies at the topAdd a task to bump the version number
gulp.task("bump", function() {
gulp.src("./project.json")
.pipe(bump())
.pipe(gulp.dest("./"));
});
Update project.json
1.0.0-*, change this to 1.0.0."gulp bump" to the bottom of "scripts" > "prepublish"Now whenever you Publish, or dnu publish or run the gulp Task Runner the version number will bump.
To display this version number in View add the following in the view;
@inject Microsoft.Extensions.PlatformAbstractions.IApplicationEnvironment appEnv
My version number is @(appEnv.ApplicationVersion)