1

When I publish my azure functions to azure not all of my referenced packages are being copied. I thus get an error stating that a specific file (Microsoft.CodeAnalysis.dll) cannot be found.

I have made sure that the package is referenced in my azure function project:

enter image description here

and have checked that it is in the .csproj file:

enter image description here

When I build locally the file is included in the \bin directory:

enter image description here

but when I publish to azure the file is missing:

enter image description here

This gives me run time error when the file is referenced:

enter image description here

How do I force the file to be included in the publish to azure, there is no option to "copy to output directory", or similar, in this instance in Visual Studio:

enter image description here

  • What method are you using to publish? Right clicking on the project and choosing "publish", zip deploy via CLI or another method? – PerfectlyPanda Sep 16 '20 at 17:53
  • I right click on the project and choose "publish". The publish profile was created from a download from the azure portal. It is therefore a "Web" publish profile (as apposed to a zip deploy) – Steve Farnaby Sep 16 '20 at 18:03
  • These are unfortunately tough to reproduce. The first thing to check is if you aren't stopping the app before you publish to try that. So stop -> publish -> start. Publishing while the site is running can occasionally have unintended side effects. There is one more spot to check where the file got left behind which is in the Build Output window. In Web Deploy that should output all the files it is changing. The next step would be to try deploying to a fresh Functions App to see if the problem is consistent. – PerfectlyPanda Sep 17 '20 at 17:26
  • Another thing to try is using zip deploy. I know that may not be what you want long term, but it can tell you something about where the problem is. Zip deploy is the default option when building your publish profile from Visual Studio or you can try a manual deployment from https://.scm.azurewebsites.net/ZipDeployUI. – PerfectlyPanda Sep 17 '20 at 17:28
  • There must be some framework differences between running a function app locally and running it in azure. When compiling the function app and running it locally the file Microsoft.CodeAnalysyis.dll is not required so was never included in my project. Only when I try run it in azure does it try to load the file and give an error. That is why I included a reference to this package in my project even though it was not required when running locally. Maybe this is why it is not included when I publish to azure? – Steve Farnaby Sep 18 '20 at 05:13
  • There are a few. If nothing else running inside the App Service sandbox is not identical to a local machine. If you remove the references from your project file does it produce the same error? – PerfectlyPanda Sep 18 '20 at 18:03
  • If I run locally I do not need a reference to Microsoft.CodeAnalysis.dll but if I run in Azure I do need a reference to Microsoft.CodeAnalysis.dll – Steve Farnaby Sep 19 '20 at 18:52
  • That should not be the case. You've been very patient and I appreciate that-- the best next step is to set you up with support so we can review our logs on what is happening to your account. If you don't have a support plan please send me an email at azcommunity(at)microsoft.com with your subscription ID and a link to this thread. I'll enable your account for one-time free support. – PerfectlyPanda Sep 21 '20 at 15:04

1 Answers1

1

This problem is resolved in Azure Functions (.NET 5.0) but in .NET Core 3.1 use

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

in the project file of Azure Functions as a workaround. Please find the details https://github.com/Azure/Azure-Functions/issues/1525

Sudipta Kumar Maiti
  • 1,669
  • 1
  • 12
  • 18