Reporting, I was using 1.0.24 fine, did a nuget update to 1.0.26, then when rebuilding ,there is an error
C:\Users\Robin.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.0.2\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets(20,5): warning : Error processing C:\TempXXXX\bin\Debug\netstandard2.0\bin\Microsoft.CSharp.dll for extension metadata: FileLoadException Could not load file or assembly 'Microsoft.CSharp, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
@soninaren
Same here. Any solution for this?
I'm having this issue as well. I had to downgrade the package back to 1.0.24 for now.
This happened to me because my TargetFramework was set to netstandard2.0. While investigating I noticed that "file new Azure Function" is using netcoreapp2.1 instead, I am now using netcoreapp2.2 and it seems to work, the compiler warning disappeared at least.
This is still happening in version 1.0.27. Is this being looked in to?
It happens for me too. Also in 1.0.27
Same here. The compilation warning persists even in 1.0.28.
I had the same error when I updated this package.
On the other hand on a new azure function I didn't have the mistake.
The difference is in the TargetFramework.
If I set netstandard2.0 then I have the error
If I put netcoreapp2.1 I have NOT the error.
If I set to netstandard2.0 I have an error about loading NewtonSoft.JSon 11.0.0.
If I set to netcoreapp2.2 or netcoreapp2.1 I have an error about loading System.Runtime 4.2.1
1.0.29 has the same error for me. Rolling back to 1.0.24 resolves error.
5>C:\Users\xxxx.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.1.2\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets(52,5): warning : Could not evaluate 'Cosmos.CRTCompat.dll' for extension metadata. Exception message: Bad IL format.
5>C:\Users\xxxx.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.1.2\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets(52,5): warning : Could not evaluate 'Microsoft.Azure.Cosmos.ServiceInterop.dll' for extension metadata. Exception message: Bad IL format.
same here even with latest version1.0.29. Downgrading to 1.0.24 worked. @ColbyTresness Is the downgrading only workaround?
@soninaren
Same error 1.0.29. Downgrade to 1.0.24 solves it.
Is this being worked on or looked in to?
@ColbyTresness , @soninaren Is this something being fixed? Looks like many people are facing same issue.
Confirmed... Downgrade to 1.0.24 is the work around. Subscribed...
This error only happens if you have
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
and use nuget for DocumentDb in your project. Once either is removed the warnings go away.
To be more specific this has something to do with cosmos db nuget Microsoft.Azure.DocumentDB.Core 2.6.0, probably previous versions as well.
Using Microsoft.NET.Sdk.Functions 1.0.29 with Microsoft.Azure.DocumentDB.Core 2.6.0
If GeneratePackagesOnBuild is set to true you will get the warnings, set to false or remove the DocumentDb nuget.
1.0.29 has the same error for me. Rolling back to 1.0.24 resolves error.
5>C:\Users\xxxx.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.1.2\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets(52,5): warning : Could not evaluate 'Cosmos.CRTCompat.dll' for extension metadata. Exception message: Bad IL format.
5>C:\Users\xxxx.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.1.2\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets(52,5): warning : Could not evaluate 'Microsoft.Azure.Cosmos.ServiceInterop.dll' for extension metadata. Exception message: Bad IL format.
are you using dependency injection ? beacuase for me i am getting the same error when i try to publish, but works locally . dont know what i am missing here
I use dependency injection and I get only If i try to publish my Azure functions.
I use dependency injection and I get only If i try to publish my Azure functions.
so the problem is, we cannot use dependency injection in Version 1.0.24 and so we need to use >= version 1.0.26 for DP and in 1.0.29 I get this error aswell, only when i try to publish my azure function.
i have also asked here the question but havnt received any feedback yet, still trying to solve
https://social.msdn.microsoft.com/Forums/azure/en-US/5b77dfb9-2fc3-4ecd-bdc4-19d142fa8d28/fucntion-sdk-1029-with-dependency-injection-and-cosmos-db-exception-message-bad-il-format?forum=AzureFunctions
I use dependency injection and I get only If i try to publish my Azure functions.
so the problem is, we cannot use dependency injection in Version 1.0.24 and so we need to use >= version 1.0.26 for DP and in 1.0.29 I get this error aswell, only when i try to publish my azure function.
i have also asked here the question but havnt received any feedback yet, still trying to solve
https://social.msdn.microsoft.com/Forums/azure/en-US/5b77dfb9-2fc3-4ecd-bdc4-19d142fa8d28/fucntion-sdk-1029-with-dependency-injection-and-cosmos-db-exception-message-bad-il-format?forum=AzureFunctions
Are you getting any runtime exceptions? i gong to try my solution.
I use dependency injection and I get only If i try to publish my Azure functions.
so the problem is, we cannot use dependency injection in Version 1.0.24 and so we need to use >= version 1.0.26 for DP and in 1.0.29 I get this error aswell, only when i try to publish my azure function.
i have also asked here the question but havnt received any feedback yet, still trying to solve
https://social.msdn.microsoft.com/Forums/azure/en-US/5b77dfb9-2fc3-4ecd-bdc4-19d142fa8d28/fucntion-sdk-1029-with-dependency-injection-and-cosmos-db-exception-message-bad-il-format?forum=AzureFunctionsAre you getting any runtime exceptions? i gong to try my solution.
i dont get run time exception but it fails to publish, so yes in Azure if i check it has run time exception, but prior to it, i already see the Bad IL Format exception message in the build output when i publish.
Steps to reproduce the problem specific to DocDb, create new solution with functions project v2 .net core 2.2. Update Microsoft.NET.Sdk.Functions nuget to v1.0.29
Add Microsoft.Azure.Functions.Extensions 1.0.0 and Microsoft.Extensions.DependencyInjection.Abstractions v3.0.0 so that you can use dependency injection.
Add any of the following nugets so that you could use use DocDb in functions:
Microsoft.Azure.Cosmos 3.2.0
Microsoft.Azure.DocumentDB.Core 2.7.0
Try injecting docdb at startup. Builds all OK with no problems. If you try to do a dotnet publish you get errors:
Could not evaluate 'Cosmos.CRTCompat.dll' for extension metadata. Exception message: Bad IL format.
Could not evaluate 'Microsoft.Azure.Cosmos.ServiceInterop.dll' for extension metadata. Exception message: Bad IL format.
Same problem happens on build if you have <GeneratePackageOnBuild>true</GeneratePackageOnBuild> in your project.
This is a huge blocker since all my functions have to use DocDb and at this point reverting back to version 1.0.24 is not an option since it doesn't support dependecy injection.
I had similiar issue today after upgrading VS and Windows.
For me solution was to delete WEBSITE_RUN_FROM_PACKAGE setting from AzureFunctions settings + changing Targer Framework to .net Core 3.0.
I had similiar issue today after upgrading VS and Windows.
For me solution was to delete WEBSITE_RUN_FROM_PACKAGE setting from AzureFunctions settings + changing Targer Framework to .net Core 3.0.
I've just tried the same steps on another computer with .net Core 3, absolutely the same problem when publishing. We're using Zip deploy for publishing functions which is the Microsoft recommended way of publishing functions.
WEBSITE_RUN_FROM_PACKAGE is also recomended for performance and other reasons, this shouldn't be a proper workaround for this issue.
I am hitting this issue on all versions more recent than 1.0.24. I too cannot rollback because I rely on DI. @fabiocav, I seem to remember that I worked with you to fix this a couple years back when I was working on the Calendar.help team at Microsoft.
Is there anything that you can do to help get this addressed?
Okay, so here is a complete hack to work around the issue described by @dlmelendez. It looks like the issue is related to the GenerateFunctionsExtensionsMetadata task in Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets. It appears that task is processing assemblies in the bin directory. When it hits the native assemblies needed by CosmosDb, it causes the error.
To workaround this, I've added the following to my .csproj file to temporarily move and later restore the native assemblies before and after the GenerateFunctionsExtensionsMetadata runs.
Sorry for the poor formatting...
<Target Name="HackMoveNativeDlls"
BeforeTargets="_GenerateFunctionsExtensionsMetadataPostPublish">
<Move
SourceFiles="$(PublishDir)bin/Cosmos.CRTCompat.dll"
DestinationFolder="$(PublishDir)bin/temp"/>
<Move
SourceFiles="$(PublishDir)bin/Microsoft.Azure.Documents.ServiceInterop.dll"
DestinationFolder="$(PublishDir)bin/temp"/>
</Target>
<Target Name="HackRestoreNativeDlls"
AfterTargets="_GenerateFunctionsExtensionsMetadataPostPublish">
<Move
SourceFiles="$(PublishDir)bin/temp/Cosmos.CRTCompat.dll"
DestinationFolder="$(PublishDir)bin"/>
<Move
SourceFiles="$(PublishDir)bin/temp/Microsoft.Azure.Documents.ServiceInterop.dll"
DestinationFolder="$(PublishDir)bin"/>
</Target>
I tried the code above. That didn't fly. I am getting the error:
2> Could not evaluate 'Cosmos.CRTCompat.dll' for extension metadata. Exception message: Bad IL format.
2> Could not evaluate 'Microsoft.Azure.Cosmos.ServiceInterop.dll' for extension metadata. Exception message: Bad IL format.
But it is still publishing at this point. At least some of the time.
This is a pretty significant problem for anyone using Cosmos and DI - any update on when it will get fixed?
I was able to publish my app using the workaround suggested by @michaelbpalmer so thank you for that.
Similar issue trying to publish Function App using DI and Cosmos, when trying to publish in Visual Studio 2019:
Could not evaluate 'Cosmos.CRTCompat.dll' for extension metadata. Exception message: Bad IL format.
Could not evaluate 'Microsoft.Azure.Cosmos.ServiceInterop.dll' for extension metadata. Exception message: Bad IL format.
Here are the packages/versions im using (using netcore 2.2)
<PackageReference Include="CsvHelper" Version="12.2.1" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.4.1" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
Any updates on this issues? I am trying to publish my function app and getting:
1>Done building project "Gateway.csproj".
2>------ Publish started: Project: Gateway (Gateway\Gateway), Configuration: Release Any CPU ------
2>Gateway -> C:\Users\Shawn\Desktop\UAPI\UniversalAPI\Gateway\Gateway\bin\Release\netcoreapp2.1\bin\Gateway.dll
2>Gateway -> C:\Users\Shawn\Desktop\UAPI\UniversalAPI\Gateway\Gateway\obj\Release\netcoreapp2.1\PubTmp\Out\
2> Could not evaluate 'Cosmos.CRTCompat.dll' for extension metadata. Exception message: Bad IL format.
2> Could not evaluate 'Microsoft.Azure.Documents.ServiceInterop.dll' for extension metadata. Exception message: Bad IL format.
2>Publishing C:\Users\Shawn\Desktop\UAPI\UniversalAPI\Gateway\Gateway\obj\Release\netcoreapp2.1\PubTmp\Gateway - 20191227164926187.zip to https://uapi-service.scm.azurewebsites.net/api/zipdeploy...
2>The attempt to publish the ZIP file through https://uapi-service.scm.azurewebsites.net/api/zipdeploy failed with HTTP status code InternalServerError.
Same here :-(
Same here... @michaelbpalmer workarround not working for me.... :'(
@shelbaz @RufusJWB @GDeroy are you seeing this issue with SDK 1.0.31?
Yes i'm using SDK 1.0.31. I finally get it work with the combination of :
@fabiocav yes, I'm using SDK 1.0.31 and still see the issue.
@RufusJWB Can you please open a new issue with the details of the issue you seeing? A standalone repro / copy of the .csproj if possible would help a lot. If other users on the thread are seeing the same issue as an existing one, please provide us the full details and possible repro. This will help us make sure all the root cases are addressed in the fix.
Most helpful comment
This happened to me because my TargetFramework was set to
netstandard2.0. While investigating I noticed that "file new Azure Function" is usingnetcoreapp2.1instead, I am now usingnetcoreapp2.2and it seems to work, the compiler warning disappeared at least.