Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build Error with pre-compiled Azure Function Library

Recently, I converted an Azure Function that used a C# script (*.csx) to a pre-complied class library using the Visual Studio Studio Tools for Azure Functions. It builds successfully in Visual Studio 2017 (as well as running and debugging too).

I'd like to build this AF library via our CI process. However, when I run the command dotnet build locally it fails with the following error:

C:\Users\ray\.nuget\packages\microsoft.net.sdk.functions\1.0.2\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(31,5): error : Could not load file or assembly 'Microsoft.Azure.WebJobs.Host, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

The same error also occurs in our CI build.

Not sure why this error is occurring and how to resolve it. Is it the version of the dotnet CLI (I'm using v1.1)? Is it something else?

like image 238
Ray Avatar asked Jan 29 '23 16:01

Ray


1 Answers

UPDATE 2018-01-08

According to a new answer by @theGRS https://stackoverflow.com/a/48156446/621827 this has been resolved.

Previous Answer

Here's what I've found.

dotnet msbuild uses the Microsoft.NET.Sdk.Functions .NETStandard 1.5 library which if you look at the dependencies on NuGet it doesn't use Microsoft.Azure.WebJobs

But if you use the Visual Studio 2017 msbuild it will use the .NETFramework 4.6 version of the library which includes Microsoft.Azure.WebJobs.

My suggestion is to use MSBuild for now.

like image 175
Stephen Gilboy Avatar answered Feb 01 '23 17:02

Stephen Gilboy