4

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?

4
  • Yes, I see the same. We'll investigate and get back to you. Commented Aug 30, 2017 at 16:07
  • @RayVega Did you solve getting this into your CI process? I'm having the same troubles (using Appveyor). Commented Sep 6, 2017 at 13:45
  • 1
    @MarcusW Yes sorta but unfortunately not with the new AF projects. I ended up converting my AF project to a plain ol' class library so that dotnet build works (e.g. removed attribute [BlobTrigger("input/{name}")], add function.json, etc.). However, you may want to try this more detailed workaround on how to use msbuild with AF projects: codescribbles.com/… Commented Sep 6, 2017 at 17:54
  • @RayVega Ok, thanks! I'll definitely give this a shot. Thank you for the quick and very helpful response! Commented Sep 7, 2017 at 6:16

2 Answers 2

7

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.

Sign up to request clarification or add additional context in comments.

6 Comments

Indeed, msbuild is the best workaround. Making it work via 'dotnet build' is something that will need some changes in the packages, and I expect this to happen later.
@DavidEbbo How can I track this issue? Thx!
@MarcusW I'll ask to get an issue opened and get back to you here.
@MarcusW I just created this issue to track: github.com/Azure/azure-functions-vs-build-sdk/issues/108. We hope to have this work done in the next month or so.
@DavidEbbo Thx a bunch!
|
1

I was having the same issue as well when running dotnet build, but no longer have this issue after updating Microsoft.NET.Sdk.Functions from 1.0.2 to 1.0.7.

Update to the latest version of this package in your Nuget package manaager and you should be able to run dotnet build again.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.