2012-09-03 156 views
8

當我用Visual Studio 2012發佈我的ASP.NET(webforms)網站時,總是會上傳所有文件。甚至圖像?Visual Studio 2012部分發布

有沒有辦法只發布更改的文件?

回答

1

不,Visual Studio中的發佈嚮導不提供此功能。

建議您在本地發佈,並且隻手動更新更改的文件。

+0

我想downvote這很糟糕。他們爲什麼要刪除這樣的功能?!?!?! –

+0

@ScottBeeson他們在VS 2012 Update 2中增加了這項功能 - http://www.west-wind.com/weblog/posts/2013/May/10/Publish-Individual-Files-to-your-Server-in-Visual -Studio-20122 –

+0

這是唯一的好方法,即使使用VS 2012 Update#2仍然覺得不方便。微軟應該爲此添加一個強大的FTP GUI應用程序。 – qakmak

3

有關記錄,VS2012的發佈配置文件中的「僅發佈更改的文件」複選框已從VS2012的發佈配置文件中刪除。前進一步,後退兩步。

+2

此外,爲了記錄:事實證明,VS2012 Web Deploy選項(而不是FTP選項)確實會部署您所做的更改。甚至還有一種奇特的「向我展示變化」GUI,它通過https發佈而不是http(或ftp),這非常棒。您的託管公司必須支持這一點,幸運的是我的(謝謝DiscountASP.net)。除了無法使用Web部署的客戶端網站之外,所有這一切都很好。 Zoidbergi,也許Web Deploy會適用於你的情況。 – gdoten

+1

我現在已經轉移到Azure,似乎只有Azure纔會上傳更改後的文件。也許MS已經用IIS8更新了部署系統? – daniel

0

使用節點 - > NPM->一飲而盡看跟蹤它們。這種方式僅在文件發生更改時才上載,並且根本不需要跟蹤變更集。無論如何,我們現在應該都在使用吞嚥。

不得不單獨手動管理所有資產,或被迫上傳整個發佈的軟件包,這簡直太瘋狂了。 我不能相信視覺工作室,即使是最新的2015版,也沒有更好的東西。真的很傷心。

這裏是我的一飲而盡腳本,這是從源(我只是清理它真的):

`

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

只是一個說明,因爲gulp 4.0仍然是alpha,所以我已經改用gulp-watch了。它速度更快,並且更好地處理事件(也支持添加和取消鏈接)。建議您修改上述內容,如果您打算使用該功能,則需要進行一次吞吐觀察。 – Barry