我想在发布web应用程序时执行grunt任务,用于开发/测试/生产。
现在,当我构建我的解决方案时,那时我已经配置为执行grunt任务。但是,当我发布我的web应用程序时,它不会执行,即使visual studio在发布之前构建解决方案。
你知道我该怎么做吗?
您没有指定Visual Studio版本。我发现这适用于VS 2015和。net core
我已经使用Grunt &项目。JSON文件。
Grunt.JS
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.initConfig({
uglify: {
options: {
mangle: false,
beautify: true
},
my_target: {
files: {
'wwwroot/app/app.js':
[
'wwwroot/*.js',
'wwwroot/services/*.js',
'wwwroot/view/**/*.js',
'wwwroot/common/*.js'
]
}
}
},
cssmin: {
options: {
shorthandCompacting: false,
roundingPrecision: -1
},
target: {
files: {
'wwwroot/app/app.css':
[
'wwwroot/*.css',
'wwwroot/view/**/*.css'
]
}
}
},
watch: {
scripts: {
files: [
'wwwroot/services/*.js',
'wwwroot/view/**/*.js',
'wwwroot/*.js'
],
tasks: ['uglify']
},
css: {
files: [
'wwwroot/*.css',
'wwwroot/view/**/*.css'
],
tasks: ['cssmin']
}
},
clean: {
prod: {
src: ['wwwroot/pdf/*']
}
}
});
grunt.registerTask('build', ['uglify', 'cssmin', 'clean']);
};
项目。Json
"scripts": {
"prepublish": [ "grunt build" ]
}