Problems using MSBuild target in TFS build (Visual Studio Online hosted build controller)

May 11, 2014 at 3:10 PM

I'm trying to have JSLint execute as part of our TFS build using a Visual Studio Online hosted build controller. I added the build-target using the JSLint NuGet package. Locally the solution builds just fine using MSBuild in a command line correctly reporting the issues from JSLint, but the TFS build fails with the following error:

"C:\a\src\XXX\ProjectX\ProjectX.csproj" (default target) (8) ->
(JSLintNet target) ->
C:\a\src\XXX\packages\JSLintNet.MSBuild.1.6.2\build\JSLintNet.MSBuild.targets(20,5): error MSB4018: The "JSLintTask" task failed unexpectedly. [C:\a\src\XXX\ProjectX\ProjectX.csproj]
C:\a\src\XXX\packages\JSLintNet.MSBuild.1.6.2\build\JSLintNet.MSBuild.targets(20,5): error MSB4018: Noesis.Javascript.JavascriptException [C:\a\src\XXX\ProjectX\ProjectX.csproj]
C:\a\src\XXX\packages\JSLintNet.MSBuild.1.6.2\build\JSLintNet.MSBuild.targets(20,5): error MSB4018: at Noesis.Javascript.CompileScript(Local<v8::Script> , Char source_code, Char* resource_name) [C:\a\src\XXX\ProjectX\ProjectX.csproj]
C:\a\src\XXX\packages\JSLintNet.MSBuild.1.6.2\build\JSLintNet.MSBuild.targets(20,5): error MSB4018: at Noesis.Javascript.JavascriptContext.Run(String iSourceCode) [C:\a\src\XXX\ProjectX\ProjectX.csproj]
C:\a\src\XXX\packages\JSLintNet.MSBuild.1.6.2\build\JSLintNet.MSBuild.targets(20,5): error MSB4018: at JSLintNet.JSLintFactory.CreateContext() [C:\a\src\XXX\ProjectX\ProjectX.csproj]
C:\a\src\XXX\packages\JSLintNet.MSBuild.1.6.2\build\JSLintNet.MSBuild.targets(20,5): error MSB4018: at JSLintNet.JSLintTask.Execute() [C:\a\src\XXX\ProjectX\ProjectX.csproj]
C:\a\src\XXX\packages\JSLintNet.MSBuild.1.6.2\build\JSLintNet.MSBuild.targets(20,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\a\src\XXX\ProjectX\ProjectX.csproj]
C:\a\src\XXX\packages\JSLintNet.MSBuild.1.6.2\build\JSLintNet.MSBuild.targets(20,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext() [C:\a\src\XXX\ProjectX\ProjectX.csproj]

Does anyone else have seen this problem? It might very easy be that some environment difference triggers this error, but is it not possible to have some more details from Noesis in order to debug this problem?
May 11, 2014 at 9:12 PM
Edited May 11, 2014 at 9:15 PM
Shame there isn't a more specific exception other than that the task failed unexpectedly.

Do you happen to know if it's running under x64 or x86 MSBuild? If it's not something to do with the bitness, then it's possible V8 can't find the bundled VCplusplus runtimes.

It may be possible to install those manually on the build machine.

Edit: Oh, and it might also be worth trying the beta. It doesn't use V8, but it does required IE9plus:
May 12, 2014 at 11:32 PM
To be honest, I do not know whether it's running x64 or x86 of MSBuild, but I will investigate. Unfortunately it's not possible to install any software on the build controller (at least as long as we are using the hosted build controller) - the current specs are as in

In the meantime I've tried with 2.0.0-beta4, but then I get a NullReferenceException instead - is something missing on the build controller?

C:\a\src\XXX\packages\JSLintNet.MSBuild.2.0.0-beta4\build\JSLintNet.MSBuild.targets(20,5): error MSB4018: The "JSLintTask" task failed unexpectedly. [C:\a\src\XXX\ProjectX\ProjectX.csproj]
C:\a\src\XXX\packages\JSLintNet.MSBuild.2.0.0-beta4\build\JSLintNet.MSBuild.targets(20,5): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object. [C:\a\src\XXX\ProjectX\ProjectX.csproj]
C:\a\src\XXX\packages\JSLintNet.MSBuild.2.0.0-beta4\build\JSLintNet.MSBuild.targets(20,5): error MSB4018: at JSLintNet.Abstractions.BrowserContext.Initialize() [C:\a\src\XXX\ProjectX\ProjectX.csproj]
C:\a\src\XXX\packages\JSLintNet.MSBuild.2.0.0-beta4\build\JSLintNet.MSBuild.targets(20,5): error MSB4018: at JSLintNet.Abstractions.AbstractionFactory.CreateBrowserContext() [C:\a\src\XXX\ProjectX\ProjectX.csproj]
C:\a\src\XXX\packages\JSLintNet.MSBuild.2.0.0-beta4\build\JSLintNet.MSBuild.targets(20,5): error MSB4018: at JSLintNet.JSLintContext..ctor(IAbstractionFactory abstractionFactory, IJsonProvider jsonProvider, IFileSystemWrapper fileSystemWrapper) [C:\a\src\XXX\ProjectX\ProjectX.csproj]
C:\a\src\XXX\packages\JSLintNet.MSBuild.2.0.0-beta4\build\JSLintNet.MSBuild.targets(20,5): error MSB4018: at JSLintNet.JSLintFactory.CreateContext() [C:\a\src\XXX\ProjectX\ProjectX.csproj]
C:\a\src\XXX\packages\JSLintNet.MSBuild.2.0.0-beta4\build\JSLintNet.MSBuild.targets(20,5): error MSB4018: at JSLintNet.JSLintTask.Execute() [C:\a\src\XXX\ProjectX\ProjectX.csproj]
C:\a\src\XXX\packages\JSLintNet.MSBuild.2.0.0-beta4\build\JSLintNet.MSBuild.targets(20,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\a\src\XXX\ProjectX\ProjectX.csproj]
C:\a\src\XXX\packages\JSLintNet.MSBuild.2.0.0-beta4\build\JSLintNet.MSBuild.targets(20,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext() [C:\a\src\XXX\ProjectX\ProjectX.csproj]
May 13, 2014 at 9:52 PM
That's great information, thank you. I'll try to spin up a VM with similar specs and see if I can replicate the problem.
May 13, 2014 at 10:29 PM
I've been been able to play a bit more with the build. Changing MSBuild to run as x86, then then it seems work with the 1.6.2 version! :) Ideally, I would like to continue with the default build settings ("Auto" which seems to imply x64), so is there anything that I could investigate why it's not working in the x64 environment?
Unfortunately the 2.0.0-beta4 fails with the same error (NullReferenceException). :(
May 15, 2014 at 6:22 AM
That's very interesting, and should make replication easier. Will update with my findings once I've had a chance to look at it.
Jun 26, 2014 at 10:33 AM
I've had a chance to do some research around this, and it seems like the x64 version of the Microsoft C runtime libraries can't be found. Normally they're already on a machine so the versions we bundle with JSLint.NET aren't used.

It's related to JavaScript.NET and it's use of V8. See the comments on redistribution here:

I've created an experimental version of JSLint.NET with the paths moved around a bit. I'm hoping this will allow the bundled versions of the Microsoft C runtime libraries to be located on your build server.

Would you mind testing out a custom NuGet package?
Jul 11, 2014 at 9:43 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Aug 13, 2014 at 11:00 AM
Updated issue 39 with my latest findings on this topic.
Dec 19, 2014 at 7:35 AM