Integrate JsLint/JsHint into the MSBuild – the easy way

I had the task to integrate static code analysis for javascript into our build. I’ve been struggling around by the solutions which I’ve found on the net, but I didn’t like any of them:

  1. Jorrit Saverda’s solution with windows scripting host:
  2. Drainbrain also with the windows scripting host:

I recognized that the JSLint for Visual Studio 2010 plugin also has an MSBuild task among its libraries. I’ve found it interesting, that nobody described it before me – at least I didn’t find any articles on the net.
So I’ve downloaded it and integrated it also into our build process on the TFS build server. The steps which I’ve done:

  1. Download the MSBuild Task from here:
  2. Create a JsLint.Targets file as follows and place it besides your downloaded and extracted binaries:
    <Project xmlns="">
      <UsingTask AssemblyFile="JSLint.MSBuild.dll" TaskName="JSLintTask"/>
        <JsFiles Include="$(JsLintedFiles)"></JsFiles>
      <Target Name="JSLintTarget" Condition="'' != 'false'">
        <Message Text="Running JSLintTask" Importance="Normal" />
  3. Configure javascript files which you want to lint and call this target from the web project:
        <!-- ... -->
      <Target Name="BeforeBuild">
        <CallTarget Targets="JSLintTarget" />
      <Import Project="..\Import\JsLintMsBuild\JsLint.Targets" />
  4. When running it on the build server I had the following error:
    The "JSLintTask" task could not be loaded from the assembly JSLint.MSBuild.dll. 
    Could not load file or assembly 'JSLint.MSBuild.dll' or one of its dependencies. 
    Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

    The solution was to Edit the build definition and change the platform under Process/3. Advanced/MSBuild Platform from Auto to x86.
    We figured out what the problem was by checking the fusion log… :)


About Tamas Nemeth

Husband and proud father in Nürnberg. I'm working as a Software Architect and an enthusiastic Clean-Coder. I spend most of my free time with my family (playing, hiking, etc...). I also play table-tennis and badminton sometimes...
This entry was posted in Technical Interest and tagged , , , , , . Bookmark the permalink.

3 Responses to Integrate JsLint/JsHint into the MSBuild – the easy way

  1. Great post! do you know how to configure rules per solution rather than per machine?

  2. Hi I would like to know if there is anything similar for EsLint

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s