2016-02-18 122 views
2

我有一個ASP.NET Core RC1項目不再正確發佈(請參見下面的發佈跟蹤輸出)。在project.json中定義的預發佈腳本中的gulp min任務正在導致該錯誤。如果我刪除它,項目會正確發佈,但不會縮小js和css文件。發佈ASP.NET Core項目時出錯

"scripts": { 
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ] 
} 

我已經把另一個Web項目的解決方案,併發布沒有錯誤,所以我認爲,消除環境問題。但是,我看不出測試項目和失敗測試項目之間的任何實質性差異。

我也刪除了失敗項目中的node_modules文件夾,強制Visual Studio再次下載所有npm包。

最後,我在VS命令提示符下面的trace中運行了dnu publish命令,這也失敗了。

任何人都可以告訴我什麼問題是從下面的錯誤跟蹤,請?

Connecting to C:\svn\Client Applications\yyy\xxx\src\xxxWeb\..\..\artifacts\bin\xxx.Web\Release\PublishOutput... 
Environment variables: 
Path=.\node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\git 
C:\Users\ptayl_000\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-final\bin\dnu.cmd publish "C:\svn\Client Applications\yyy\xxx\src\xxxWeb" --out "C:\Users\ptayl_000\AppData\Local\Temp\PublishTemp\xxx.Web104" --configuration Release --no-source --runtime dnx-clr-win-x86.1.0.0-rc1-final --wwwroot "wwwroot" --wwwroot-out "wwwroot" --iis-command "web" --quiet 
Microsoft .NET Development Utility Clr-x86-1.0.0-rc1-16202 
Executing script 'prepublish' in project.json 
v0.10.31 
npm WARN package.json [email protected] No description 
npm WARN package.json [email protected] No repository field. 
npm WARN package.json [email protected] No README data 
[07:36:31] Using gulpfile C:\svn\Client Applications\yyy\xxx\src\xxxWeb\gulpfile.js 
[07:36:31] Starting 'clean:js'... 
[07:36:31] Starting 'clean:css'... 
[07:36:31] Finished 'clean:js' after 1.68 ms 
[07:36:31] Finished 'clean:css' after 1.99 ms 
[07:36:31] Starting 'clean'... 
[07:36:31] Finished 'clean' after 9.03 μs 
[07:36:32] Using gulpfile C:\svn\Client Applications\yyy\xxx\src\xxxWeb\gulpfile.js 
[07:36:32] Starting 'min:js'... 
[07:36:32] Starting 'min:css'... 
[07:36:32] Finished 'min:css' after 61 ms 
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : events.js:72 
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error :   throw er; // Unhandled 'error' event 
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error :    ^
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : Error 
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error :  at new JS_Parse_Error (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:196:18) 
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error :  at js_error (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:204:11) 
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error :  at croak (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:675:9) 
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error :  at token_error (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:683:9) 
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error :  at expect_token (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:696:9) 
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error :  at expect (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:699:36) 
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error :  at C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:1252:13 
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error :  at C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:722:24 
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error :  at expr_atom (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:1182:35) 
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error :  at maybe_unary (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:1358:19) 
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : The 'prepublish' script failed with status code 8. 

2>Publish failed due to build errors. Check the error list for more details. 

更新gulp min任務包含下面的代碼(從gulp.js):

gulp.task("min:js", function() { 
    return gulp.src([paths.js, "!" + paths.minJs], { base: "." }) 
     .pipe(concat(paths.concatJsDest)) 
     .pipe(uglify()) 
     .pipe(gulp.dest(".")); 
}); 

UPDATE2:event.js

var rx = require("rx"); 

function normalizeKeypressEvents(args) { 
    return { value: args[0], key: args[1] }; 
} 

module.exports = function(rl) { 
    return { 
    line: rx.Observable.fromEvent(rl, "line"), 

    keypress: rx.Observable.fromEvent(rl, "keypress", normalizeKeypressEvents), 

    normalizedUpKey: rx.Observable.fromEvent(rl, "keypress", normalizeKeypressEvents).filter(function (e) { 
     return e.key && (e.key.name === "up" || e.key.name === "k"); 
    }).share(), 

    normalizedDownKey: rx.Observable.fromEvent(rl, "keypress", normalizeKeypressEvents).filter(function (e) { 
     return e.key && (e.key.name === "down" || e.key.name === "j"); 
    }).share(), 

    numberKey: rx.Observable.fromEvent(rl, "keypress", normalizeKeypressEvents).filter(function (e) { 
     return e.value && "123456789".indexOf(e.value) >= 0; 
    }).map(function(e) { 
     return Number(e.value); 
    }).share(), 

    spaceKey: rx.Observable.fromEvent(rl, "keypress", normalizeKeypressEvents).filter(function (e) { 
     return e.key && e.key.name === "space"; 
    }).share(), 

    }; 
}; 
+0

您在錯誤列表選項卡中遇到什麼錯誤? –

+0

與上面跟蹤中以「c:\ Program Files ...」開頭的相同。 –

+0

你能發佈你的gulp min任務的內容嗎? –

回答

1

原來,這是一個一塊應用程序JavaScript是causin g「gulp min」任務失敗。罪魁禍首是以下看似無害的一段代碼:

$http.get(uri, { params: { config } }).then(function (data) { 
    return data; 
}); 

我仍然無法看到任何問題,但隨着代碼變得多餘,我刪除,並解決了這個問題的方式。

1

我得到相同的問題(即使在相同的行號)。保羅自己的回答給了我一個線索,要仔細看看我自己的.js

我註釋掉了大部分文件,然後逐步取消註釋了代碼塊,直到錯誤恢復。

而這個有問題的代碼? 這是使用模板串線是問題:

rtUl.insertAdjacentHTML("beforeend", `<li>${el.toString()}</li>`); 

更改回簡單的串連工作:

rtUl.insertAdjacentHTML("beforeend", "<li>" + el.toString() + "</li>"); 

看來,醜化無法讀取字符串模板(還)。