发布ASP.NET Core项目时出错

时间:2016-02-18 08:04:41

标签: npm visual-studio-2015 asp.net-core

我有一个不再正确发布的ASP.NET Core RC1项目(请参阅下面的发布跟踪输出)。 gulp min中定义的预发布脚本中的project.json任务导致错误。如果我删除它,项目会正确发布,但不会缩小js和css文件。

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

我已经在解决方案中添加了另一个Web项目,并且发布时没有错误,所以我认为这可以消除环境问题。但是,我看不出测试项目和失败的项目之间有什么实质性的差别。

我还删除了失败项目中的node_modules文件夹,以强制Visual Studio再次下载所有npm包。

最后,我在VS命令提示符下面的跟踪中运行了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 ASP.NET@0.0.0 No description
npm WARN package.json ASP.NET@0.0.0 No repository field.
npm WARN package.json ASP.NET@0.0.0 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(),

  };
};

2 个答案:

答案 0 :(得分:1)

原来这是一个应用程序javascript导致" gulp min"任务失败。罪魁祸首是以下看似无害的代码:

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

我仍然无法看到它的任何问题,但随着代码变得多余,我删除了它并以这种方式解决了问题。

答案 1 :(得分:1)

我遇到了同样的问题(即使在相同的行号上)。保罗自己的回答给了我一个线索,仔细看看我自己的.js

我注释掉了大部分文件,然后是逐步取消注释的代码块,直到错误消失为止。

违规代码? 使用模板字符串的这一行是问题所在:

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

将其更改回简单的连接工作:

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

似乎uglify无法读取字符串模板。