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) ?

serhio
  • 28,010
  • 62
  • 221
  • 374

4 Answers4

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)

serhio
  • 28,010
  • 62
  • 221
  • 374
13

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.

Nick Martyshchenko
  • 4,231
  • 2
  • 20
  • 24
  • 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. – Adam Anderson Aug 07 '14 at 12:06
8

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.

Nabil Sham
  • 2,305
  • 4
  • 26
  • 38
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

Alois Cochard
  • 9,812
  • 2
  • 29
  • 30