【问题标题】:Build fails when building Azure function with MSBuild version 15 from command line从命令行使用 MSBuild 版本 15 构建 Azure 函数时构建失败
【发布时间】:2017-06-17 11:16:30
【问题描述】:

我在 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 的项目一样简单地做一个 nuget restore
  • 我刚刚尝试使用nuget restore mysolution.sln 并收到消息Nothing to do. None of the projects in this solution specify any packages for NuGet to restore. 如果我知道Visual Studio 如何恢复包,我可以复制它。
  • 我刚刚尝试了我的测试应用程序 (github.com/davidebbo-test/FunctionAppVS2017_3Preview),nuget restore 后跟 msbuild 效果很好。确保从 VS 2017 preview 的开发提示中执行此操作。

标签: azure msbuild azure-functions


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-28
    • 2018-03-11
    • 1970-01-01
    • 1970-01-01
    • 2014-03-03
    • 2018-02-18
    • 2018-10-12
    • 2015-07-14
    相关资源
    最近更新 更多