- Jorrit Saverda’s solution with windows scripting host: http://blog.jorritsalverda.com/2012/05/msbuild-by-convention.htmlt
- Drainbrain also with the windows scripting host: http://drainbrain.wordpress.com/2012/04/12/jslint-with-msbuild/
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:
- Download the MSBuild Task from here: http://jslint4vs2010.codeplex.com/releases/view/95840
- Create a JsLint.Targets file as follows and place it besides your downloaded and extracted binaries:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <UsingTask AssemblyFile="JSLint.MSBuild.dll" TaskName="JSLintTask"/> <PropertyGroup> <JsLintErrorsAsWarnings>true</JsLintErrorsAsWarnings> </PropertyGroup> <ItemGroup> <JsFiles Include="$(JsLintedFiles)"></JsFiles> </ItemGroup> <Target Name="JSLintTarget" Condition="'' != 'false'"> <Message Text="Running JSLintTask" Importance="Normal" /> <JSLintTask SourceFiles="@(JsFiles)" OptionsFile="$(SolutionDir)Import\JsLintMsBuild\StandardRuleset.xml" TreatViolationsAsWarnings="$(JsLintErrorsAsWarnings)" /> </Target> </Project>
<PropertyGroup> <!-- ... --> <JsLintedFiles>$(SolutionDir)WebProject\Scripts\*.*</JsLintedFiles> </PropertyGroup> <Target Name="BeforeBuild"> <CallTarget Targets="JSLintTarget" /> </Target> <Import Project="..\Import\JsLintMsBuild\JsLint.Targets" />
- 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… :)