从命令行使用 MSBuild 版本 15 构建 Azure 函数时构建失败

Build fails when building Azure function with MSBuild version 15 from command line

我在 Visual Studio 2017 年创建了一个 Azure 函数应用程序(详情 here)并且应用程序在 Visual Studio 中构建没有问题。但是,当我尝试使用 MSBuild 版本 15 从命令行(简单地 运行 msbuild.exe mysolution.sln)构建应用程序时,出现如下错误:

error CS0234: The type or namespace name 'Azure' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) 这很可能是因为应用程序默认引用 Microsoft.Azure.WebJobs,如前所述 here.

所以我想我需要以某种方式恢复 Microsoft.Azure.WebJobs 包,但我不确定如何手动恢复 Azure 函数应用程序中的包。我创建了一个 project.json 文件并在其中列出了包,但那没有用。然后我创建了一个 packages.json nuget 文件,但也没有用。有什么想法吗?

解决了这个问题 - 我需要先 运行 msbuild.exe mysolution.sln /t:restore 然后 运行 msbuild.exe mysolution.sln 我从信息 here.[=13 中找到的=]