Downloads
Update
An updated version of the line count utility described in an earlier article is now available. This now:
- Does basic C++ line counting of Visual Studio.NET projects and solutions, as well as C# and VB.NET as previously.
- Counts the total number of code files and displays them in the summary section.
- Allows the summary to be selected (by dragging over it) and copied to the clipboard with Ctrl-C.
Unfortunately for C++ projects I don’t think there’s an easy way of identifying auto-generated code, and hence the application will always return zero for code-generated lines for C++ projects.
Code Project
An abbreviated version of these articles is available on the Code Project.
Rich, the .zip file for the executable seems to be corrupted (source is OK).
David
It’s working fine for me. What problem are you seeing?
Zip file is def corrupted.
Guys
I have rebuilt the executable and reposted the zip. I think it should be OK now.
Rich
Thx This Works Great!
Hi Rich,
I found this via the Code Project.
I’m trying to generate useful information about Lines of Code during the build process. I can’t tell from the articles if there is a command line option or a non-interactive (html/xml) output option. Have you considered using such?
Hi!
Thank you for the great utility. When I am analysing a vb.net 2003 project, I get the following error message in FindCodeFilesAndAddToChildContainersList: Invalid character in xml.
The reason is, that a filename in my *.proj contains a german umlaut (Ü), which is not XML-conform. Do you know a quick workaround?
Thanks!
Tobias
Great little utility, just what i was looking for. cheers.
Hi Rich,
Thanks for a great tool. I have one question, I tried it on a web service project (2005) and it did not pick up the program files in the app_code folder. Is there a setting that I can make to have it do that?
Thanks,
John
You rock.
Thanks,
Stephen and Andy
Wow,
Much thanks for the software. 🙂
Any chance of adding a print to screen option? so i could save it as a picture (jpeg, gif, bmp, etc)?
Much thanks anyway
Tzach
This tool is very useful for my MSE project 🙂
Thanks a lot
Very helpfull ! Thanx a lot!!!!
Hi,
I found your application extremely useful. I made a couple of modifications to it if you are interested.
We use a lot of codeSmith templates in our projects so I wanted to to take the templates, and generated code into consideration. I also wanted to process .dbp prjoject (database projects).
I modified the code to handle .dbp, .sql, and .cst (code smith template) files and it seems to work fine. I had to modify the dataset, add some counters, etc. I also updated it to 3.5 of the framework and use some Linq stuff for array processing and the like.
If you are interested in the changes let me know and I can zip and get them to you.
Thanks again for this head start, your code was easy to read and modify and was a pleasure to work with.
Thanks,
Jeff
Nice Tool.Found your tool after a long search in web
I was looking for a way to count lines in a large web application that I developed at work, and found this. It didn’t quite work for me out of the box (.NET Web Projects don’t have project files so this utility only found and counted my Helpers code, which is compiled in it’s own proj file to a DLL). However with the great documentation and design of the application I was able to modify the project in about an hour to do exactly what I wanted.
Thanks for the great utility, and for making it open-source so I could make it work for me too!
PS: If you want the code to make it work with Web Projects shoot me an email, I’d be happy to send it over. I did it with very minor changes to the CodeContainer and Factory classes and adding some items to the interface, all of which were needed to allow the utility to count based on Directory and added a class (called WebProject) which inherits and implements CodeContainer.
thnx for this great tool… if you just want to use it for counting lines etc. it is even better then code metric in vs.
A suggestion would be to show the raw C# line count, this is what I neeed.
Thanks for the tool. It works well. Curious, why is it so big (>60MB)?
Thanks! Very quick and useful.
Thanks! This is quite useful.
One great feature would be the ability to export the data generated to various formats – e.g., .xls, .html, etc.
Thanks.
Great work Rich! Really helped me. 🙂
I use LineCount to count lines in C++ files based on .NET Solution. I found out that all files with relative path (i.e. ..\..\filename) has 0 lines
Why ?
I had this same problem so I downloaded the source code, and took a look.
Anyway, I fixed the ..\..\ by doing the following (no guarantees about fixing or breaking other relative paths though):
Open the Project.cs file in the CodeContainers folder.
Look for the AddCodeFileToList function (line 69 in mine).
Locate the following line of code in the function (line 73 in mine):
if (codeFileRelativeName.StartsWith(“.”)) codeFileRelativeName = codeFileRelativeName.Substring(2);
Comment this line out, ie:
//if (codeFileRelativeName.StartsWith(“.”)) codeFileRelativeName = codeFileRelativeName.Substring(2);
Or replace it with:
if (codeFileRelativeName.StartsWith(“.\\”)) codeFileRelativeName = codeFileRelativeName.Substring(2);
After I did this, all paths with ..\..\ loaded correctly.
The reason this was breaking was because the path was being changed from something like “..\\..\\SomeFileName.cs” to “\\..\\SomeFileName.cs”
Anyway, it ‘should’ be fairly safe to comment the line out as the ‘Path.Combine’ function seems to be intelligent enough to handle relative paths (at least on mine it does).
The 2nd alternative basically checks to see if the path starts with .\ and omits it, but leaves paths with ..\ alone.
Thank you very much for this, Rich.
I have made the necessary changes so it also works with Visual Studio 2010 C++ projects. Email me at “email at rennie-petersen dot eu” if you’d like me to send these changes to you.
Very handy – ideal for situations where you don’t have (or wan’t) nDepend installed. Many thanks.