Visual Studio 2012 部分发布

9
当我使用Visual Studio 2012发布我的ASP.NET(WebForms)网站时,总是上传所有文件,包括图片?有没有一种方法只发布更改的文件?
4个回答

8

它也适用于2013年! - Dave Alperovich

3

值得注意的是,VS2012发布配置文件中的“仅发布更改的文件”复选框已从VS2012发布配置文件中删除。这是一步向前,两步向后。


2
进一步记录:事实证明,与FTP选项相比,VS2012 Web Deploy选项确实只会部署您所做的更改。甚至有一个花哨的“显示更改”GUI,并且它发布在https而不是http(或ftp)上,这很棒。您的托管公司必须支持此功能,幸运的是我的托管公司支持(感谢DiscountASP.net)。除了我的一个客户站点无法使用Web Deploy之外,一切都很好。Zoidbergi,也许Web Deploy在您的情况下可以使用。 - Glenn Doten
1
我现在转移到了Azure,似乎只有更改的文件才会上传。也许微软已经使用IIS8更新了部署系统? - daniel

1

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

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


我非常想要踩这个 Stack Overflow 的帖子。为什么他们要移除这样一个功能?!?!? - user736893
@ScottBeeson 他们在VS 2012更新2中添加了此功能 - http://www.west-wind.com/weblog/posts/2013/May/10/Publish-Individual-Files-to-your-Server-in-Visual-Studio-20122 - el vis
这是唯一的好方法,即使使用VS 2012 Update#2仍然感觉不方便。微软应该为此添加一个强大的FTP GUI应用程序。 - qakmak
我采用了这种方法,但我使用FileZilla只覆盖更新的文件,这样我就不必手动操作了。 - crichavin

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 ) )
      ;
    });
});`

只是一条注释,由于gulp 4.0仍处于alpha版本,我已经转换到gulp-watch。它更快,并且处理事件更好(还支持添加和取消链接)。如果您要使用它,请建议您修改上面的内容,以实现gulp-watch的实现。 - Barry

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接