react.net clearscriptv8 compiler error

error
Here’s another one for the error message Googlers. Recently I ran into a nasty build error on TeamCity after adding React.NET Nuget packages to an ASP.NET MVC solution.
Locally everything built just find, but on TeamCity the build failed with the following error message when trying to compile the MVC views:

[AspNetCompiler] ASPNETCOMPILER error ASPCONFIG: Could not load file or assembly 'ClearScriptV8-32.DLL' or one of its dependencies. The specified module could not be found.

Normally you get this type of errors when an assembly can’t be found or isn’t copied to the bin folder for some reason.
In this case it turns out to be more or less the opposite case. The DLL is in the bin folder, but .NET should be ignoring it. Apparently ASP.NET tries to load all DLL files in the bin folder, which it should not do for the v8 ones, making it crash and burn.
The clue came from this StackOverflow post and this blog post. The fix in the blog post is a bit hacky but pointed me in the right direction. The SO answer to change the web.config is spot on.

So the trick is to exclude the offending binaries by listing them in the web.config compilation section:

<configuration>
    <system.diagnostics>
        <trace autoflush="true" />
    </system.diagnostics>
    <system.web>
        <compilation>
            <assemblies>
                <remove assembly="ClearScriptV8-64" />
                <remove assembly="ClearScriptV8-32" />
                <remove assembly="v8-ia32.dll" />
                <remove assembly="v8-x64.dll" />
                       ....
            </assemblies>
        </compilation>

This way the DLL’s are no longer automatically scanned, and your build can nicely go on compiling those MVC views without any trouble.

Photo by strange little woman on stream, cc-licensed.

Leave a Reply

Your email address will not be published. Required fields are marked *