Skip to content

Azure Functions FileNotFoundException workaround

Alexander edited this page Jul 22, 2020 · 2 revisions

When running in Azure Functions you may stuck into exception

System.IO.FileNotFoundException HResult=0x80070002 Message=Could not load file or assembly 'Microsoft.CodeAnalysis, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. Source=RazorEngineCore StackTrace: at RazorEngineCore.RazorEngineCompilationOptions..ctor() at RazorEngineCore.RazorEngineCompilationOptionsBuilder..ctor(RazorEngineCompilationOptions options) 

It is due to known Azure Functions build bug: https://github.com/Azure/azure-functions-host/issues/5894

To work around the issue, add the following to your csproj file to prevent the cleanup:

 <PropertyGroup> <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> </PropertyGroup> 

Thanks to @AndyMDoyle

Clone this wiki locally