9

当我使用 Visual Studio 2012 发布我的 ASP.NET (webforms) 网站时,总是上传所有文件。甚至图像?

有没有办法只发布更改的文件?

4

4 回答 4

8

仅供参考:微软在 VS 2012 Update #2 中添加了该功能:

http://www.west-wind.com/weblog/posts/2013/May/10/Publish-Individual-Files-to-your-Server-in-Visual-Studio-20122

于 2013-05-24T10:09:41.990 回答
3

作为记录,VS2012 的发布配置文件中的“仅发布更改的文件”复选框已从 VS2012 的发布配置文件中删除。前进一步,后退两步。

于 2012-11-21T15:51:22.250 回答
1

不,Visual Studio 中的发布向导不提供此功能。

一个建议是在本地发布并且仅手动更新更改的文件。

于 2012-09-03T14:26:52.677 回答
0

使用 node->npm->gulp watch 来跟踪它们。这样,它仅在文件更改时上传,您根本不需要跟踪变更集。无论如何,这些天我们都应该使用 gulp。

不得不单独手动管理所有资产,或者被迫上传整个发布的包,这简直是疯了。我简直不敢相信 Visual Studio,即使是最新的 2015 版,也没有更好的东西。真的很伤心。

这是我的 gulp 脚本,它来自(我刚刚清理了它):

`

var gulp  = require('gulp'),
gutil = require('gulp-util'),
vftp = require('vinyl-ftp');

var fconfig {
    host: "127.0.0.1",
    port: "21",
    user: "root",
    password: "top-secret-tacos",
    simultaneous_connections: 5,
    file_lock_delay: 450, // ms to wait for lock release. "meh".
    local_path: ".",
    remote_path: "/my_path/as_seen/in_ftp/",
    globs: {
        "/assets/src/**/*.*css",
        "/assets/src/**/*.js",
        "/assets/dist/**/*",
        "/**/*.ascx", // track .net changes and upload instantly when saved.
        // don't track visual studio stuff.
        "!./obj/**/*",
        "!./bin/**/*",
        "!./packages/",
        "!./App_LocalResources/**/*",
        "!./vs/**/*",
        "!./properties/**/*",
        "!./node_modules/**/*"
    }
};


    // Add debounce to gulp watch for FTP
(function ftp_debounce_fix(){

  var watch = gulp.watch;

  // Overwrite the local gulp.watch function
  gulp.watch = function(glob, opt, fn){
    var _this = this, _fn, timeout;

    // This is taken from the gulpjs file, but needed to
    // qualify the "fn" variable
    if ( typeof opt === 'function' || Array.isArray(opt) ) {
      fn = opt;
      opt = null;
    }

    // Make a copy of the callback function for reference
    _fn = fn;

    // Create a new delayed callback function
    fn = function(){

      if( timeout ){
        clearTimeout( timeout );
      }
      console.log("Delayed Task setup[450].");
      timeout = setTimeout( Array.isArray(_fn) ? function(){
        _this.start.call(_this, _fn);
      } : _fn, fconfig.file_lock_delay);

    };

    return watch.call( this, glob, opt, fn );
  };

})();

function getFtpConnection() {  
    return vftp.create({
        host: fconfig.host,
        port: fconfig.port,
        user: fconfig.user,
        password: fconfig.pass,
        parallel: fconfig.simultaneous_connections,
        log: gutil.log
    });
}
gulp.task('deploy', function() {
    var conn = getFtpConnection();
    return gulp.src(fconfig.globs, { base: fconfig.local_path, buffer: false })
        .pipe( conn.newer( fconfig.remote_root ) ) // only upload newer files 
        .pipe( conn.dest( fconfig.remote_root ) )
    ;
});
gulp.task('deploy-watch', function() {
    var conn = getFtpConnection();

    gulp.watch(fconfig.globs)
    .on('change', function(event) {
      console.log('Changes detected! Uploading file "' + event.path + '", ' + event.type);

      return gulp.src( [event.path], { base: fconfig.local_path, buffer: false } )
        .pipe( conn.newer( fconfig.remote_root ) ) // only upload newer files 
        .pipe( conn.dest( fconfig.remote_root ) )
      ;
    });
});`
于 2016-09-30T16:19:32.273 回答