Could not load file or assembly 'Microsoft.CodeAnalysis" in visual studio 2015 - visual-studio

I am creating an android app in visual studio 2015. While building the solution I am getting this error :
The specified task executable "csc.exe" could not be run. Could not load file or assembly 'Microsoft.CodeAnalysis, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
I have update my visual studio as well. but nothing is working for me.
Here is snapshot of error:

try to run visual studio as administrator or repair your visual studio from programs
see this post:
Visual Studio 2012 csc.exe Error. Executable not valid for OS

Related

Visual Studio Installer - Unable to acquire updated Visual Studio Installer

I have a problem with installing Visual Studio 2022 from https://visualstudio.microsoft.com/fr/downloads/
I got this error when I try to run VisualStudioSetup.exe .This is my first attempt
Unable to acquire updated Visual Studio Installer. This problem occurs when the installer on your machine is the same or lower than the version to update. If this is your first attempt, we recommend that you Continue to install the Visual Studio update.
[Continue] [Cancel]
When I click continue and this error appear
Unable to launch the installer. Error: Could not load file or assembly 'System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
I 've try to unistall and ran setup.exe again but it didn't work..

Visual Studio 2013 - errors when editing build definition

I get several errors when trying to edit my build definition. This has worked fine before, but I suspect that installing Visual Studio 2015 has messed things up.
History:
First I had Visual Studio 2013 Ultimate. At this time there were no problems
Recently I installed Visual Studio 2015 Professional.
For licensing reasons, I had to remove VS 2013 Ultimate and install VS 2013 Professional instead.
In VS 2013 Professional-> Team Explorer->Builds I now get an error when I edit my build definition. I suspect that the installation/reinstallation is the cause.
Under Process->Items to build I click the add button and get this error message:
[A]Microsoft.TeamFoundation.Build.Workflow.Activities.BuildSettings cannot be cast to [B]Microsoft.TeamFoundation.Build.Workflow.Activities.BuildSettings. Type A originates from 'Microsoft.TeamFoundation.Build.Workflow, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in the context 'Default' at location 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.TeamFoundation.Build.Workflow\v4.0_10.0.0.0__b03f5f7f11d50a3a\Microsoft.TeamFoundation.Build.Workflow.dll'. Type B originates from 'Microsoft.TeamFoundation.Build.Workflow, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in the context 'Default' at location 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.Build.Workflow.dll'.
You can also try to:
Clean the Cache folder on client computer. The folder path is: C:\Users\username\AppData\Local\Microsoft\Team Foundation\x.0\Cache. (x is the TFS version)
Clean the Cache folder on Server machine. The folder path is: C:\ProgramData\Microsoft\Team Foundation\Web Access\Cache_v10.0
Try resetting settings and add-in settings (devenv /ResetSettings) and (devenv /ResetSkipPkgs), try rebuilding all templates (devenv /setup).

VS 2013 and MSBuild

I've recently upgraded to Visual Studio 2013, which has caused back to back problems when building externally using MSBuild (API or Executable with command line args)
Issue #1
When building with MSBuild it doesn't generate Fake assemblies which are required for our Unit Tests, this leads to build failures. A simple build in visual studio fixes this temporarily, until a new fake assembly needs to be generated.
Issue #2
When running code analysis this complains with the following:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(284,5):
error MSB4127: The "CodeAnalysis" task could not be instantiated from the assembly "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\CodeAnalysis\.\FxCopTask.dll".
Please verify the task assembly has been built using the same version of the Microsoft.Build.Framework assembly as the one installed on your computer and that your host application is not missing a binding redirect for Microsoft.Build.Framework. Unable to cast object of type 'Microsoft.Build.Tasks.CodeAnalysis' to type 'Microsoft.Build.Framework.ITask'.
I only have Visual Studio 2013 installed on my machine, apparently installing an older version could fix the issue, but it's not something which I can do. (VS 2013 Ships with its own MSBuild 12.0 which is located in a different directory to the previous MSBuild).
I'm unsure why Visual Studio is behaving any differently to MSBuild, i'm simply pointing to the solution file like so...
msbuild.exe "path\solution.sln" /property:Configuration=Debug
So, Visual Studio 2013 comes with a new version of MSBuild i.e. MSBuild 12.0. Once installed, it changes the path so that the new version is used by default.
Looks like your solution compiles with visual studio 2012, you can either specify the full path to msbuild.exe such as
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild "path\solution.sln" /property:Configuration=Debug
or set the visual studio 2012 environment variables by running the following before executing msbuild
"%VS110COMNTOOLS%"\vsvars32.bat // VS2012 environment variables
EDIT: Using MSbuild 12.0 assemblies "C:\Program Files (x86)\MSBuild\12.0\Bin\" fixes the issue with the code Analysis bug.

Visual Studio unable to read the project file (anymore)

Ever since my latest windows update, (which system restore is failing to undo) I can't load any projects with visual studio 2010. The project are greyed out (unavailable) and when I try to reload them I get the error:
C:\Users\Benoit\Documents\Visual Studio 2010\Projects\Test123\Test123\Test123.csproj : error : Unable to read the project file 'Test123.csproj'. Could not load file or assembly 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
I tried creating new projects: same error
I tried creating different type of projects (command prompt, silverlight, windows phone): same error
Deleting the .suo and .user files did not change anything
I did not move the projects
Using Visual Studio 2010 with Windows Vista
It looks like the Global Assembly Cache (GAC) is messed up, or possibly the update has done something with the Microsoft.Build assembly file itself.
Try repairing .NET 4.0, and if that does not work you can try completely uninstalling and reinstalling the framework.

Error loading Visual Studios 2012

Everytime i try to open Visual Studios 2012, an error message displays
" Could not load file or assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e25' or one of its dependencies. The system cannot find the file specified."
Any idea what is wrong? How to fix this?
Try to Uninstall the Visual Studio that you have and download it from http://www.microsoft.com/visualstudio/esn/2013-preview. It works for me perfectly.

Resources