如何在Visual Studio 2015 asp.net 5中调试Typescript? [英] How to debug Typescript in Visual Studio 2015 asp.net 5?

查看:122
本文介绍了如何在Visual Studio 2015 asp.net 5中调试Typescript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法从visual studio 2015 CTP6 asp.net 5应用程序调试typescript文件?
如果没有,那么也许有一种方法来配置源地图文件,所以当我在浏览器中调试它们,并可以自动保存对服务器上的.ts文件的更改?
这可能很困难,因为.ts文件是由gulp编译的,但也许有人找到了很好的解决方案?

解决方案

p>调试使用Visual Studio的脚本使用正确的设置。


  1. 首先你确定你创建源地图当将typescript编译成javascript时。所以你应该在每个xxx.js附近都有一个xxx.js.map文件。



    通过在Visual Studio之外运行typescript编译器来获取源地图不会造成任何困难,在tsc命令行添加

       -  sourcemap%1.ts 

    您的gulp脚本通常会默认创建源地图。


  2. 配置您的网页Visual Studio中的应用程序



    Internet Explorer 设置为启动浏览器。我只使用IE工作,不要任何其他浏览器工作。 (编辑:在某个地方我看到有一个Webkit调试桥,所以Chrome调试应该是可行的,但我不记得源码。)



    在项目属性中,进入Web选项卡,并在底部配置Debuggers部分:禁用所有调试器!您可能会看到此错误消息:



    您尝试启动调试器,但是根据您当前在Web属性页上的调试设置没有调试过程。



    当不要打开页面,等待来自另一个进程的请求选项时,并禁用ASP.NET调试。请在Web属性页面上检查您的设置,然后重试。如错误消息所示,Web属性顶部的开始操作应该是另一个选项,例如当前页



    设置现在或更高版本的Visual Studio中的ts代码中的断点



    点击 F5


虽然您可以使用Visual Studio编辑器来调试和编辑ts文件,但编辑和继续将无法正常工作,目前没有任何浏览器可以重新加载js和js.map文件并继续。 (如果我错了,请纠正任何人,我会很开心。)


Is there a way to debug typescript files from visual studio 2015 CTP6 asp.net 5 application? If not then maybe there is a way to configure source map files, so when I debug them in browser and can automatically save changes to my .ts files on server? This might be hard, because .ts files are compiled by gulp, but maybe somebody found good solution for that?

解决方案

Debugging typescript with Visual Studio works with the right settings.

  1. First you make sure that you create source maps when compiling typescript to javascript. So you should have an xxx.js.map file near every xxx.js.

    Getting source maps by running the typescript compiler outside of Visual Studio does not cause any difficulty, at the tsc command line add

    --sourcemap %1.ts
    

    your gulp script will usually create sourcemaps by default.

  2. Configure your web application in Visual Studio.

    Set Internet Explorer as the start browser. I got it working only with IE and dont think any other browser will work. (edit: Somewhere I read that there is a Webkit debugging bridge, so Chrome debugging should be possible, but I do not remember the source.)

    In the project properties go to the "Web" tab and configure the "Debuggers" section at the bottom: Disable all debuggers! This is counter intutitive and you might see this error message:

    You have attempted to start the debugger, but based on your current debug settings on the Web properties page there is no process to debug.

    This occurs when the "Don't open a page. Wait for a request from another process" option is selected, and ASP.NET debugging is disabled. Please check your settings on the Web properties page and try again. As the error message says, the Start Action at the top of the Web properties should be another option, like "Current page".

    Set breakpoints in your ts code inside Visual Studio now or later.

    Hit F5

While you can use the Visual Studio Editor to debug and edit ts files, "Edit and Continue" will not work, there is currently no browser that can reload js and js.map files and continue. (Correct me anyone if I am wrong and I will be happy.)

这篇关于如何在Visual Studio 2015 asp.net 5中调试Typescript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆