Dealogic / cloc-vsts-extension

Build task for Visual Studio Team Services (VSTS) to count lines of code.
MIT License
5 stars 2 forks source link

Can't find cloc.exe #9

Closed dustinwoodhouse closed 5 years ago

dustinwoodhouse commented 5 years ago

I've added cloc as a step in my build pipeline. It downloads successfully and then fails because it can't locate cloc.exe...

2019-01-15T19:04:11.9575687Z ##[section]Starting: Count lines of code... 2019-01-15T19:04:11.9579353Z ============================================================================== 2019-01-15T19:04:11.9579442Z Task : Count Lines of Code 2019-01-15T19:04:11.9579482Z Description : Count Lines of Code with cloc CLI by Al Danial. 2019-01-15T19:04:11.9579522Z Version : 1.1.2 2019-01-15T19:04:11.9579582Z Author : Dealogic 2019-01-15T19:04:11.9579621Z Help : More information cloc 2019-01-15T19:04:11.9579661Z ============================================================================== 2019-01-15T19:04:12.3336825Z task display name: Count lines of code... 2019-01-15T19:04:12.3346536Z working folder: D:\a\1\s 2019-01-15T19:04:12.3356697Z cloc-cli download url: https://github.com/AlDanial/cloc/releases/download/1.80/cloc-1.80.exe 2019-01-15T19:04:12.3358026Z arguments: --exclude-dir=.gitignore --exclude-ext=.md 2019-01-15T19:04:12.3368795Z Downloading cloc.exe from 'https://github.com/AlDanial/cloc/releases/download/1.80/cloc-1.80.exe' 2019-01-15T19:04:13.6897941Z Download is completed. 2019-01-15T19:04:13.6898354Z Executing command: cloc.exe --exclude-dir=.gitignore --exclude-ext=.md --sum-one --md --out cloc.result.md 2019-01-15T19:04:16.8508360Z ##[error]Unhandled: Command failed: cloc.exe --exclude-dir=.gitignore --exclude-ext=.md --sum-one --md --out cloc.result.md

                   cloc -- Count Lines of Code

Usage: cloc.exe [options] <file(s)/dir(s)/git hash(es)> Count physical lines of source code and comments in the given files (may be archives such as compressed tarballs or zip files) and/or recursively below the given directories or git commit hashes. Example: cloc src/ include/ main.c

cloc.exe [options] --diff <set1>  <set2>
    Compute differences of physical lines of source code and comments
    between any pairwise combination of directory names, archive
    files or git commit hashes.
    Example:    cloc --diff Python-3.5.tar.xz python-3.6/

cloc.exe --help shows full documentation on the options. http://github.com/AlDanial/cloc has numerous examples and more information.

dustinwoodhouse commented 5 years ago

The problem appears to be the name of the executable. Has this use case never been tested before? I certainly can't be the first person using this as a VSTS (azure devops) plugin in their build pipeline.

jkanczler commented 5 years ago

It's working in our build pipeline.

This is what you're trying to achieve (arguments input):

--exclude-dir=.gitignore --exclude-ext=.md

The problem with this the --exclude-dir option. The .gitignore is a file. Maybe you wanted to use .git as directory. The path to analyze input is missing too.

Example arguments input for a .NET application:

. --exclude-dir=bin,obj,packages,.vs,.git

As you can see it starts with a '.'. Specifies that we would like to scan the actual folder. The --exclude-dir option excluding bin, obj, packages, .vs and .git directories.

The pipeline logged the following:

2019-01-16T10:40:17.1370522Z Executing command: cloc.exe . --exclude-dir=bin,obj,packages,.vs,.git --sum-one --md --out cloc.result.md
2019-01-16T10:40:25.2618244Z       50 text files.
2019-01-16T10:40:25.2619113Z classified 50 files
2019-01-16T10:40:25.2619269Z       49 unique files.                              
2019-01-16T10:40:25.2619399Z       26 files ignored.
2019-01-16T10:40:25.2619557Z Wrote cloc.result.md

I suggest to run cloc.exe manually on your machine. Test what arguments are good for you, before configuring the build step.

dustinwoodhouse commented 5 years ago

Thanks @jkanczler, the missing path was the problem. Adding the path fixed it.