7

One team will analyze our .NET solution code. Before that, we wondered how many lines of code contains our project.

Is there a way to achieve find out this (in VS 2010) ?

3
  • 1
    Duplicate of: stackoverflow.com/questions/1244729/… Commented Oct 15, 2010 at 10:39
  • 4
    Not duplicate, because of VS 2010 Commented Oct 15, 2010 at 10:44
  • @serhio The linked duplicate's accepted answer specifically refers to VS2010 Commented Jul 16, 2019 at 13:34

4 Answers 4

16

Open the search (ctrl+shift+f),

Search for all files in the solution (*.cs or *.vb), use regular expression ^ (line beginning).

Wait.

PS.
you can filter out empty lines with ^.+$ (a @ssc-hrep3 suggestion)

Sign up to request clarification or add additional context in comments.

2 Comments

+1, that's a nice, quick and dirty way, at least there is no need to install additional bloatware just for a line count.
You can filter out empty lines with ^.+$
12

You can also use DPack:

DPack is a FREE collection of Microsoft Visual Studio 2008/2010 tools. DPack is designed to greatly increase developer's productivity, automate repetitive processes and expand upon some of Microsoft Visual Studio features.

DPack is very handy but you can use it only for solution statistics:

Solution statistics feature allows one to evaluate the size of the entire solution. It collects information on all projects in the currently opened solution. The information is collected on code files only and includes: total number of lines, total number of code lines, total number of comment lines and total number of empty lines in each project. Solution statistics can be exported to a comma delimited CSV file using Export button.

1 Comment

Another reason to love DPack! This is one of the few extensions I always install with Visual Studio. Low overhead, fast, and greatly speeds navigation in any solution, especially large ones.
9

Using powershell move to the folder containing your project files and enter the command

(dir -r -include   *.cs,*.vb | select-string . ).count

replace "cs" "vb" with file extensions you want to include in your count.

1 Comment

Does this count empty lines too ?
4

Yes

Here is a tutorial: http://blogs.msdn.com/b/habibh/archive/2009/10/27/how-to-count-the-lines-of-code-loc-in-your-application-using-visual-studio.aspx

Or you can use a dedicated tools like this one: http://code.msdn.microsoft.com/LOCCounter

3 Comments

this is about a project, or a solution?
first link: project, second link access directly to source code so you can count multiple solutions/projects
First link doesn't work with standard edition. Second link needs additional software installed.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.