Afer changing TypeScriptOutDir breakpoints are never hit - node.js

I am using Visual Studio Professional 2013 Update 3 and I have created a Node console Application with the "hello world" log instruction. If I set a breakpoint in this instruction and then I run the debugger, it works perfectly fine. It hits the breakpoint and then I can debug as expected (just to make clear that my .map files are created and working correctly).
Now, I clean the project (remove the app.js and app.js.map generated files). I edit the .njsproj file and I add:
<TypeScriptOutDir>lib</TypeScriptOutDir>
I open the project again, update the startup file path by adding the additional "\lib" folder and I start debugging. It runs the code but it does not hit the breakpoint.
Why is not hitting the breakpoint? How the Visual Studio hit detection is working for typescript (node.js) projects since no .pdb files have been created when compiling? And how can I fix that so I can debug a compiled code that it's not located at the same folder as my source files?
Any suggestion, idea, feedback will be really appreciated. Thank you.
Note:
Checking the .js.map file generated in "\lib" I can see how the .ts file reference has an additional "..\" So the reference is alright. Anyway it seems like the problem is detecting the hit in the .js file rather than mapping the .js to .ts lines.
Update:
Steps to reproduce:
Create a new project "Blank Node.js Console Application".
Unload the project.
Edit .njsproj xml and add this line: <TypeScriptOutDir>lib</TypeScriptOutDir>
Reload project.
Update startup file in the project by adding the "\lib" to the path.
Open "app.ts" file.
Set the breakpoint in the unique line of code "1. console.log('Hello world')"
Start debugging.
Result: The app.js is generated in the "\lib" folder, VS runs the file with node, it prints the "Hello world" and finishes. No breakpoint hit.
Is it possible that setting breakpoints over a .ts file is always assuming that the .js file generated will be in the same folder as the .ts file?
I have tested setting the and to "lib" without any success in having the breackpoint in the .ts file and being hit.
Note:
If I set the breakpoint directly over the file generated in "\lib\app.js" it gets hit and the Visual Studio starts debugging but I still need it working setting the breakpoints in the .ts files.
Update2
Using the debug-working project (without the TypeScriptOutDir line in the .njsproj) I've manually changed the .js.map file where it says:
"sources":["app.ts"] to "sources":["app.ts"]
I have changed it to app2.ts:
"sources":["app.ts"] to "sources":["app2.ts"]
app2.ts is a non existing file. When we run the project now the breakpoint is not hit.
I have also tried with an absolute path:
"sources":["W:/VS2013/projects/NodejsConsoleAppHit/app.ts"]
and it also works, but again if pointing to a non existing file it does not work:
"sources":["W:/VS2013/projects/NodejsConsoleAppHit/app2.ts"]
It looks like the app.js.map file is the responsible of mapping the breakpoints we set in the .ts file to the lines in the .js file.
Then, what is wrong with the app.js.map file generated in the lib folder?
If we take a look to this file we can see a reference to the .ts file in the previous folder:
sources":["../app.ts"]
This should be alright since the path from "/lib/app.js" to "app.ts" is "../app.ts". But the result when we run the project is that the breakpoint is not hit.
Why? I have no idea and that is what I need to figure out.
I have also tried to manually modifying this references between relative and absolute without any success...
I have created two "Node.js console application" projects and set a breakpoint in the "hello world" log instruction.
The NodejsConsoleAppHit is the one WITHOUT the TypeScriptOutDir config. Is the one that generates the files in the project root folder and hits the breakpoint.
https://www.dropbox.com/s/mniuhm8mgnly3ff/NodejsConsoleAppHit.zip?dl=0
The NodejsConsoleAppNoHit is the one WITH the TypeScriptOutDir config. Is the one that generates the files in the lib folder and does not hit the breakpoint.
https://www.dropbox.com/s/dyadwxupltcg6gc/NodejsConsoleAppNoHit.zip?dl=0

According to this work item on the Node.js Tools for Visual Studio in CodePlex:
https://nodejstools.codeplex.com/workitem/1428
The issue has been taken in account and fixed. I have tested it myself with "NTVS 1.0 RC VS 2013" and seems to be working fine.
You can get it choosing "NTVS 1.0 RC VS 2013" from the NTVS downloads page:
https://nodejstools.codeplex.com/releases/view/149714
or directly going here:
https://nodejstools.codeplex.com/downloads/get/946895
I have to say that we have been using node-inspector (https://github.com/node-inspector/node-inspector) for debugging in the meantime and it is a tool that works pretty fine and solved all our problems.
Personally still find the VS integration more convenient for ourselves. This is a matter of taste since, after this update of node.js tools, both seem to work fine.

Related

Why are Nodejs breakpoints in VS Code disabled depending on whether the full path appears in the tab title?

A breakpoint in my Mocha test works when set on the exact same line in one VS Code tab but not in another.
The difference: If the full path appears in the tab, then breakpoints work. (Second item in screenshot.)
But if the filename, without path, appears in the tab header, then breakpoints all become Unverified (gray) during execution.
Repro steps:
If you open files from the Explorer view, the bug occurs.
If you open files using CTRL-P, as in the screenshot, then both
variants are usually available, and choosing the one with/without
path gives the different behaviors.
How can I avoid this without continually checking which path variant is appearing?
(Here is a GitHub ticket that I opened.)
Answer (figured out on the GitHub thread):
My workspace path was under a symbolic link (Ubuntu).
VS Code apparently dereferences symbolic links to give Node a path that it can work with, to support breakpoints.
VS Code also shows the file at the correctly referenced path in my workspace folder as I defined it (under the symbolic link).

How to configure VS Code with Microsoft C++ compiler which works in all workspaces?

I am a beginner in C++ and I am interested in using the MSVP compiler for compiling my code as well as Visual Studio Code.
I am facing a problem with the configuration of the MSVP compiler with VS Code.
I have read the article about the configuration given at this link-https://code.visualstudio.com/docs/cpp/config-msvc.
I have configured the compiler and everything works fine.
According to the article, each and every project I make requires this configuration, which needs to be copied and pasted in the .vscode folder of every project I make.
But, I am not interested in doing this. I want that each project or I make should automatically take up this configuration.
I tried figuring out this problem on my own by putting two or three code files in the folder named helloworld because then all these files would take the same configuration and would get debugged separately, but the main problem is created by this part of the tasks.json file:
"args": [
"/EHsc",
"/Zi",
"/Fe:",
"helloworld.exe",
"helloworld.cpp"
]
This part tells the compiler that the code file HAS to be helloworld.cpp
and the executable has to be named helloworld.exe.
In the end, I would like to tell that I want VS Code to be configured like the Visual Studio IDE, where you just type the code by creating a project and the executable gets named just like the code file.
For example, the executable of hello.cpp is named hello.exe, and one doesn't need to copy and paste any configuration file anywhere.
Also, I would like to tell that I HAVE to use VS Code only.
Any help would be appreciated.
Thank you !

error FTK1013: could not find unicode byte order marker

What does this error mean:
Error 8 error FTK1013: could not find unicode byte order marker in the file
tracking log file: c:\Users\ASUS\documents\visual studio
2010\Projects\project\project\Debug\CL.write.1.tlog.
The tracking data is invalid. c:\Users\ASUS\documents\visual studio
2010\Projects\project\project\FileTracker project
.tlog files are created as the build goes, writing dependencies, command lines, etc, not anything directly in your control. You're not supposed to see that kind of error unless maybe your disk is full or you manage to launch multiple builds on the same project somehow.
Exit VS, delete the debug folder. Look around in task manager for stray processes or reboot.
Reopen the solution and try build, with some hope the problem just goes away for good.
If someone faced mentioned error you should know that it's VS2010 issue only.
It's already tested and checked. Be careful with following project names:
mt, link, midle, cl, bscmake, rc
In most cases you could just build your project again and buld process will be finished successfully, but if you want to avoid of this error at each RE-build(or first buid, or automatic build by some of control system) you have to rename your project.
Also described and discussed in:
MS Social thread "Error FTK1013: could not find unicode byte order marker in file tracking log file"
Delete the Debug folder in the Visual Studio project folder. Re-build.
I am sharing one workaround for this issue.
Disable /MP for the project(s). Set value "NO" in the "Multi-processor Compilation" setting under Configuration Properties > C/C++->general in the project property window. It worked for me.
Follow these 4 simple steps:
1) go in the Debug folder.
2) Search for the file.
3) Delete the file.
4) Build the project again.

MSBuild error "CSC : error CS2001: Source File 'x' could not be found" with Linked Files after upgrading to Visual Studio 2012

After automatically upgrading the project file for a .Net 4.0 web application to work with Visual Studio 2012 everything worked ok at first however when compiling I got lots of errors like this:
Description : Source File '..\..\..\..\..\File Path' could not be found
File : CSC
And when trying to build using MSBuild (passing just the project full path, with no additional parameters) in the "Developer Command Prompt for VS2012" I got basically the same errors:
"CSC : error CS2001: Source File 'x' could not be found"
All errors refer to Linked Files (aspx,cs,etc) located in other web applications projects located at a different deep in our code Branch (that's why all the '....\' at the beginning of the paths)
To me it looks like a problem with the file Length, I had the same problem a while ago when building the projects on our CI server using MSBuild, I was able to manage it by manipulating the project files before building them using a custom script without the need to move the branch around or reduce the deep of the projects, I didn't have to move anything, the important thing at the time it was that developers using Visual Studio 2010 could compile everything without problems. I learned by this that compiling/Building with MSBuild was different that with DevEnv/VS, and for example MSBuild didn't support building Setup projects and DevEnv did.
Since this is happening now with VS 2012/DevEnv 2012 , plus that VS 2012 doesn't support setup projects anymore (like msbuild), plus VS/DevEnv have the same problem with the file length, it looks like VS 2012 its finally using msbuild under the hood or are more tightly integrated, however I didn't find any article to confirm this.
Changing the branch structure/changing the deep of the projects it’s not an option right now due to several reasons (large code base, high number of projects, risk, timing, effort, etc.).
Does someone have an alternative solution or a fix for this issue in Visual Studio 2012?
Regards,
P.D.: BTW I already checked this post MSBuild error with linked files but like I said before changing the paths its not an option right now.
Try getting the Build Logs,
http://msdn.microsoft.com/en-us/library/vstudio/ms171470.aspx
it seems that csc task could not find the source file. One cause it you import the wrong file.
so you have to edit the project file via normal Text Editor.
I found a solution to this issue, when you linked the file, you relative path is recognized by msbuild and go back from there it become your path in a long path however you can change it in the project definition doing right click/unload the project/ and change the path from ../../../ to $(SolutionDir)/../.. until find the file to link, note: it's extend the character from 255 to 300 character.
Check that you have the latest version of the linked files from the other projects. Visual Studio will NOT automatically get them if they belong to another project.
Check that the linked paths are indeed correct. You can monitor what files VS.NET and MSBUILD are trying to access with the help of the SysInternals ProcMon tool (filter on process names and filter out all successes)
If you suspect that the path length is the problem (this will also be visible in the ProcMon tool), you can try to shorten them by linking to the absolute path (C:\X\Y\Z) instead of a relative path (......\Z). The location of the linked files can then remain unchanged.
My 2 cents to this problem... In my case, I had a file created in one project (i.e. ConfigModel) and I had a link to this file in another project but when I renamed the file ConfigModel in the first project to LoginModel for example, it didn't rename the link in the second project causing this error to occur.
I know that i did this question a while ago but for what is worth, The approach that we finally went for was:
Locating the files that were reported as too long.
Reduce the full path length of those files, by reducing the length of the name and/or
the length of the container folder or reducing the folder nesting
level. Therefore reducing the full path length.
Update the links of the changed files (re-linking) on the dependant projects.
This solved the problem with Visual Studio 2012 on developers workstations and on our CI/Deploy servers that used MSbuild.
For my scenario this approach was less risky,and implied less effort than moving complete projects/solutions to reduce their folder nesting level or reducing the folder names, and have to update all the references of the dependant project/solutions.
Ok, I hit this and solved it today. I found it by following a msdn tutorial (https://msdn.microsoft.com/en-us/library/ms379563%28v=vs.80%29.aspx) and here's the command that broke for me:
csc /t:library /out:MyCodeLibrary.dll simpleType.cs
Giving me the message
error CS2001: Source file 't:librabry' could not be found
Which worked after changing the original command to the following:
csc /target:library /out:MyCodeLibrary.dll simpleType.cs
I'm not sure why the short version of the /target flag causes this error, but I've not found anywhere else online noting this cause specifically so I wanted to record it here.
This problem arose for me when I reverted to an earlier version of a git repository. Apparently I didn't add the project file to the repo so when it reverted it didn't revert the project file also. What I did to clear it up was to exclude the missing .cs file from the project by clicking on the missing file in the project Explorer. It was easy to find since it was marked with a warning triangle. Then rebuild the entire solution.
Verify whether the files mentioned in the error do not exist in the corresponding folder.
If their non-existence is intentional, edit the .csproj files and remove the reference for those files.
Build again.
I inherited this issue from a project somebody else was working on, in my case was a .cs file supposed to be generated by an Entity Framework .tt template, but for some reason it wasn't, so the compiler was going all CS2001 about that. I had to update the template and manually run it, everything worked after that.

Including files in VS 2012

I want to include a library - I've downloaded it and found exactly four files inside:
.h
.lib
.dll
.def
I've put the header file inside of my project. That's the only thing I did - and the visual throws an error that it cannot open the .lib file.
So I immediately wanted to beg for help on stackoverflow, but I've decided to do a little research first. I've found out that the .dll file should be placed inside of the windows/SYSWOW64 location (for my 64-bit windows 7), I placed it there but VS still displays the same error.
How should I deal with that? Did I missed some step during the "installation"? If so, which ones?
You have to specify the path to the library (*.lib) in your project settings.
(You can put it also into your directory with sources)
The presence of DLL file during build is not required.

Resources