Could not load file or assembly 'Microsoft.CodeAnalysis, version= 1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependenc
As pointed out by @CaptainAmerica the solution is to update the CodeDom assembly from NuGet. One should point out how to do this in Visual Studio. I found the solution here:
https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/
Basically, in the Visual Studio menu select:
Tools-> Nuget Package Manager -> Package Manager Console
In the console that appears at the bottom of Visual Studio run this command:
Install-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
If any of the options doesn't work, here is the detailed guide to handle this scenario....
First of all version is important. Notice the version mentioned in the error...
Could not load file or assembly 'Microsoft.CodeAnalysis, version= 1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
If you see above error it means that it's not able to find version 1.3.1. Now please create new VS project. No preferences, it can be just simple console application. Now once project template is ready, go to Package Manager and run following command with your specified version...
Install-Package Microsoft.CodeAnalysis -Version 1.3.1
This will install all packages. Let it complete. Once it's done. We don't need this newly created project at all. You can delete it completely. Seriously! you can delete it. We did this because we wanted that package installed at global nuget level. When you install something, nuget stores it at global level of your machine as well. Path will be something like this...
C:\Users\<<Your Windows User>>\.nuget\packages
You can know your path by following...
%USERPROFILE%\.nuget\packages
Now you will see your required Microsoft.CodeAnalysis.dll there in following folder...
C:\Users\<<Your Windows User>>\.nuget\packages\Microsoft.CodeAnalysis.Common\1.3.1\lib\net45
Please note that above path contains version number (1.3.1). If your version is different, look into that version folder.
Now that you have dll with you, all that you need to do is add that dll to GAC. For that you will need GacUtil.exe
This file get installed along with Visual Studio already. You can search "GacUtil" in C drive. For me it's there on below path...
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools
Now run command prompt as Administrator and navigate current directory to your path containing GacUtil. The run below command to install that dll in GAC.
gacutil
-i C:\Users\<<You Windows User>>\.nuget\packages\Microsoft.CodeAnalysis.Common\1.3.1\lib\net45\Mi
crosoft.CodeAnalysis.dll
Basically providing path to dll we installed globally. It will show message on successful installation.
That's all! Now start your Visual Studio again and you will get this issue fixed.
I had the same problem with Visual Studio 2015 Update 2, to solve the problem globally for all solutions, update to Visual Studio 2015 Update 3. Here is a link: Download from here