如果我使用" dotnet new angular"创建项目,我可以在Visual Studio 2017中调试C#和Typescript代码。但在Visual Studio Code中,我只能调试C#。当我尝试在任何Typescript指令上放置一个断点时,它会说:"没有为该文档加载符号"。由于它在VS 2017中运行良好,在我看来,Typescript配置应该没问题。
当我在VSCode中打开项目时,它表示"您的项目中缺少构建和调试所需的资产。加他们?"我回答"是"然后它添加" .vscode"包含launch.json和tasks.json的文件夹。也许它没有为调试器添加正确的启动配置? launch.json中的唯一配置是针对" .NET Core Launch(web)"和#34; .NET Core Attach"。
我安装了Debugger for Chrome 3.5.0扩展程序。
这是生成的launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/spa.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
答案 0 :(得分:2)
由VSCode生成的launch.json文件存在问题。我需要为Chrome调试器添加配置。我还需要添加一个“复合”配置,以便在同一个会话中调试C#和Typescript。以下是所需的其他配置。选择“Full stack”配置来调试C#和Typescript。
我在Github的Microsoft / vscode-recipes存储库中获得了auchenberg的帮助,从而找到了解决方案。我创建了一个拉取请求来添加这个新配方。 (见:https://github.com/Microsoft/vscode-recipes/tree/master/Angular-SpaTemplates)
所需的其他配置是:
$(document).ready(function() {
Highcharts.setOptions({
global: {
useUTC: false
}
});
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
//defaultSeriesType: 'spline',
},
title: {
text: 'Live random data'
},
events:{
load: refreshChart()
},
xAxis: {
type: 'datetime',
},
tooltip: {
valueSuffix: ' C'
},
yAxis: {
type: 'linear',
title: {
text: 'Temperature ( C)'
},
},
series: [{}]
});
$.getJSON("index.php", function(json) { /*Get the array data in data.php using jquery getJSON function*/
options.series[0].data = json; /*assign the array variable to chart data object*/
chart = new Highcharts.Chart(options); /*create a new chart*/
});
function refreshChart(){ /*function is called every set interval to refresh(recreate the chart) with the new data from data.php*/
setInterval(function(){
$.getJSON("index.php", function(json) {
options.series[0].data = json;
chart = new Highcharts.Chart(options);
});
},6000);
}