10/04/2017

Why I hate Roslyn even more

Home



In my previous post I wrote about my problem with "empty" projects and Roslyn. The symptom was that in some cases according to Roslyn my C# projects didn't contain any files. For quite a long time, I haven't been able to find a solution. Especially because I couldn't reproduce problem on my local machine. Fortunately, today I noticed exactly the same problem on another computer.

Knowing that Roslyn likes to fail silently I started investigation my telling Visual Studio to break when any exception is thrown. Then I run my program and I stared analyzing strange exceptions like COMException, DllNotFoundException or InvalidProjectFileException. Especially, the last one was interesting. It was thrown in Microsoft.Build.dll and the included message was:

The tools version "15.0" is unrecognized. Available tools versions are "14.0", "2.0", "3.5", "4.0".

Following my intuition, I opened the csproj file for my project. It looked in this way:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...
</Project>
So my project was created with tools in the version 12.0. Well, it was neither equal to 15.0 nor on the list of available versions but I decided to try my luck. I updated ToolsVersion="12.0" to ToolsVersion="14.0" and run my program one more time.

And you know what? It worked this time! Gosh, I hate fighting with such silly problems. Again, it confirms that Roslyn fails in slowly, silently and not in the clear way! Do not do that to your clients.

I suspect that the problem might be somehow related to the version of MSBuild that is installed on the machine but for now I'm not sure. Do you know something?

*The picture at the beginning of the post comes from own resources and shows Tatry Mountains.

0 comments:

Post a Comment