MVC 6 now uses project.json
to track version and you can bump this number using gulp-bump.
Version Bumping
Add gulp-bump to package.json > devDependencies
gulp-bump": "1.0.0"
Edit gulpfile.js
- Add
bump = require("gulp-bump")
to the dependencies at the top
Add a task to bump the version number
gulp.task("bump", function() {
gulp.src("./project.json")
.pipe(bump())
.pipe(gulp.dest("./"));
});
Update project.json
- By default the MVC template sets the version number to
1.0.0-*
, change this to 1.0.0
.
- Add
"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.
Bonus
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)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…