Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build Error - Roslyn MSB3883: Unexpected exception: System.IO.FileNotFoundException for System.Security.Principal.Windows

I regularly receive the following during build in Visual Studio 2017:

1>------ Build started: Project: Library, Configuration: Debug Any CPU ------

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets(84,5): error MSB3883: Unexpected exception: 

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets(84,5): error : System.IO.FileNotFoundException: Could not load file or assembly 'System.Security.Principal.Windows, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets(84,5): error : File name: 'System.Security.Principal.Windows, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets(84,5): error : at Microsoft.CodeAnalysis.CommandLine.BuildServerConnection.GetPipeNameForPathOpt(String compilerExeDirectory)

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets(84,5): error : at Microsoft.CodeAnalysis.BuildTasks.ManagedCompiler.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands)

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets(84,5): error : WRN: Assembly binding logging is turned OFF.

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets(84,5): error : To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets(84,5): error : Note: There is some performance penalty associated with assembly bind failure logging.

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets(84,5): error : To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Nothing seems to consistently fix it. Sometimes clean and rebuild works. Sometimes restarting Visual Studio works. But both have also seemed to have no effect so it seems more related to time or some other processes.

Update I just tried upgrading from version 15.6.7 to 15.8.1 so we'll see if that fixes it.

Update #2 The issue has not resurfaced for me in version 15.8.1 but there are many reports in the comments that the issue still exists as late as 15.8.5. The issue might not be version specific, but is instead some corruption that a reinstall or upgrade can sometimes fix.

like image 840
b_levitt Avatar asked Aug 29 '18 02:08

b_levitt


2 Answers

I have found that simply restarting my machine fixes this issue. I only get this issue on initial build of a project, this issue does not occur for me on existing solutions.

I have only managed to test this theory a couple of times so not sure it will work every time. But I thought I would post as it might same someone a bit of time.

This was with Visual Studio Enterprise version 15.8.6.

like image 95
Sebastian Avatar answered Nov 15 '22 06:11

Sebastian


Upgrading from Visual Studio version 15.6.7 to the latest version solves this issue.

like image 6
Josh Noe Avatar answered Nov 15 '22 06:11

Josh Noe