在VS 2017中升级到Angular 6后,TS断点不起作用

时间:2018-08-15 23:16:46

标签: debugging visual-studio-2017 angular6

我当前正在使用Angular 6,.NET Core 2.1,VS2017。在升级到Angular 6之前,我正在使用Angular4。TS文件中的断点工作正常。我已经升级到Angular 6,之后所有TS断点都无法正常工作。

获取有关断点的以下提示。

该断点当前不会被命中。尚未为此文档加载任何符号。

这是我的packages.json文件:

"scripts": {},
"devDependencies": {
"@angular/animations": "6.1.0",
"@angular/cli": "^6.1.1",
"@angular/common": "6.1.0",
"@angular/compiler": "6.1.0",
"@angular/compiler-cli": "6.1.0",
"@angular/core": "6.1.0",
"@angular/forms": "6.1.0",
"@angular/http": "6.1.0",
"@angular/platform-browser": "6.1.0",
"@angular/platform-browser-dynamic": "6.1.0",
"@angular/platform-server": "6.1.0",
"@angular/router": "6.1.0",
"@ngtools/webpack": "^6.1.1",
"@types/chai": "4.1.4",
"@types/jasmine": "2.8.8",
"@types/webpack-env": "1.13.6",
"angular2-router-loader": "0.3.5",
"angular2-template-loader": "0.6.2",
"aspnet-prerendering": "^3.0.1",
"aspnet-webpack": "^3.0.0",
"awesome-typescript-loader": "5.2.0",
"bootstrap": "4.1.3",
"chai": "4.1.2",
"css": "2.2.3",
"css-loader": "1.0.0",
"es6-shim": "0.35.3",
"event-source-polyfill": "0.0.12",
"expose-loader": "0.7.5",
"extract-text-webpack-plugin": "3.0.2",
"file-loader": "1.1.11",
"html-loader": "0.5.5",
"isomorphic-fetch": "2.2.1",
"jasmine-core": "3.1.0",
"jquery": "3.3.1",
"json-loader": "0.5.7",
"karma": "2.0.5",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-cli": "1.0.1",
"karma-jasmine": "1.1.2",
"karma-webpack": "3.0.0",
"popper.js": "^1.12.9",
"preboot": "6.0.0-beta.4",
"raw-loader": "0.5.1",
"reflect-metadata": "0.1.12",
"rxjs": "6.2.2",
"style-loader": "0.21.0",
"to-string-loader": "1.1.5",
"typescript": "2.9.2",
"url-loader": "1.0.1",
"webpack": "^4.16.3",
"webpack-cli": "^3.1.0",
"webpack-hot-middleware": "2.22.3",
"webpack-merge": "4.1.3",
"zone.js": "0.8.26"
  },
  "dependencies": {
"ng-bootstrap": "^1.6.3",
"ngx-loading": "^1.0.14",
"ngx-pagination": "^3.1.1",
"npm": "^6.2.0",
"w3-css": "^4.1.0"
  }

这是我的webpack配置文件

const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const AotPlugin = require('@ngtools/webpack').AotPlugin;
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;

module.exports = (env) => {
// Configuration in common to both client-side and server-side bundles
const isDevBuild = !(env && env.prod);
const sharedConfig = {
    stats: { modules: false },
    context: __dirname,
    resolve: { extensions: ['.js', '.ts'] },
    output: {
        filename: '[name].js',
        publicPath: 'dist/' // Webpack dev middleware, if enabled, handles requests for this URL prefix
    },
    module: {
        rules: [
            { test: /\.ts$/, use: isDevBuild ? ['awesome-typescript-loader?silent=true', 'angular2-template-loader', 'angular2-router-loader'] : '@ngtools/webpack' },
            { test: /\.html$/, use: 'html-loader?minimize=false' },
            { test: /\.css$/, use: ['to-string-loader', isDevBuild ? 'css-loader' : 'css-loader?minimize'] },
            { test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' }
        ]
    },
    mode:'development',
    plugins: [new CheckerPlugin(),
    new webpack.ContextReplacementPlugin(
        /angular(\\|\/)core/,
        path.resolve(__dirname, './ClientApp')
    )]
    //,
    //performance: {
    //    maxEntrypointSize: 512000,
    //    maxAssetSize: 512000
    //}
};

// Configuration for client-side bundle suitable for running in browsers
const clientBundleOutputDir = './wwwroot/dist';
const clientBundleConfig = merge(sharedConfig, {
    entry: { 'main-client': './ClientApp/boot.browser.ts' },
    output: { path: path.join(__dirname, clientBundleOutputDir) },
    plugins: [
        new webpack.DllReferencePlugin({
            context: __dirname,
            manifest: require('./wwwroot/dist/vendor-manifest.json')
        })
    ].concat(isDevBuild ? [
        // Plugins that apply in development builds only
        new webpack.SourceMapDevToolPlugin({
            filename: '[file].map', // Remove this line if you prefer inline source maps
            moduleFilenameTemplate: path.relative(clientBundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk
        })
    ] : [
            // Plugins that apply in production builds only
            new webpack.optimize.UglifyJsPlugin(),
            new AotPlugin({
                tsConfigPath: './tsconfig.json',
                entryModule: path.join(__dirname, 'ClientApp/app/app.browser.module#AppModule'),
                exclude: ['./**/*.server.ts']
            })
        ])
});

// Configuration for server-side (prerendering) bundle suitable for running in Node
const serverBundleConfig = merge(sharedConfig, {
    resolve: { mainFields: ['main'] },
    entry: { 'main-server': './ClientApp/boot.server.ts' },
    plugins: [
        new webpack.DllReferencePlugin({
            context: __dirname,
            manifest: require('./ClientApp/dist/vendor-manifest.json'),
            sourceType: 'commonjs2',
            name: './vendor'
        })
    ].concat(isDevBuild ? [] : [
        // Plugins that apply in production builds only
        new AotPlugin({
            tsConfigPath: './tsconfig.json',
            entryModule: path.join(__dirname, 'ClientApp/app/app.server.module#AppModule'),
            exclude: ['./**/*.browser.ts']
        })
    ]),
    output: {
        libraryTarget: 'commonjs',
        path: path.join(__dirname, './ClientApp/dist')
    },
    target: 'node',
    devtool: 'inline-source-map'
});

return [clientBundleConfig, serverBundleConfig];
};

帮助我解决此问题。

2 个答案:

答案 0 :(得分:0)

  

在VS 2017中升级到Angular 6后,TS断点不起作用

这是.NET core 2.1的一个已知问题,开发人员社区中的许多其他社区也报告了该问题:

TS breakpoints not working with ASP.NET Core 2.1

MS开发团队已解决了Visual Studio最新的15.9预览版的问题。您可以从以下URL(https://visualstudio.microsoft.com/vs/preview/)下载最新的预览。

同时,他们建议解决方法是让开发人员在创建新项目时将.NET core SDK 2.0定位为目标,并在项目创建后将项目目标运行时更新为2.1。

希望这会有所帮助。

答案 1 :(得分:0)

尝试删除sln文件附近的vs文件夹。还要确保正确设置了调试选项,并且启用了Javascript调试。我对chrome有类似的问题,但在IE中工作正常。在升级vs 2017之后,在运行我的网站时,它询问我是否要启用Java脚本调试。单击“是”后,我可以在chrome中调试。我的猜测是,对于chrome ja调试,必须启用vs中的某些设置