Can't build Azure Functions project from dotnet CLI

989 Views Asked by At

I'm having some troubles with a newly created Azure Functions project (the new precompiled version). It's a TimerTrigger function which I created from template in VS2017.

It builds just fine from within Visual Studio, but when I try to build it with the .NET Core CLI (msbuild) I get the following error:

C:\Users\f00.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.Extensions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. [C:\Repos\Test\testproject\src\functions-project\functions-project.csproj]

Version: "Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core"

My guess is that when building from within VS it uses a different version of msbuild, or a different configuration. But I'm not sure how to fix it. The end goal here is being able to build and deploy with Appveyor, but I get the same error there of course.

Update

I've tried creating a new functions project and a TimerTrigger from scratch, but to no avail - getting the same error again. I even tried creating an HttpTriggerbut that didn't work either :(

1

There are 1 best solutions below

1
On

As ilyaf metioned that we need to add the before build script dotnet restore, I test it on my side, it works corretly. Following is my detail steps.

1.Create an Azure function project with VS2017 template.

2.Push it to the github.

3.Add the project to Appveyor

enter image description here

4.Set the environment and build

enter image description here

enter image description here

  1. Check that it build successfully.

enter image description here

enter image description here