【问题标题】:Azure DevOps Pipeline failing on Build step due to "missing" package. How do I resolve this issue?由于“缺少”包,Azure DevOps Pipeline 在构建步骤中失败。我该如何解决这个问题?
【发布时间】:2020-06-13 15:11:06
【问题描述】:

我目前正在尝试使用 Azure DevOps Pipeline 为我的 ASP MVC Web 应用程序设置持续部署。每次签到都会触发此管道。每次管道运行时,它都会在构建步骤中失败。它显示的错误是:

    Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Nothing to do. None of the projects specified contain packages to restore.
D:\a\1\s\FantasyLeague\FantasyLeague.csproj(345,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\3.1.101\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\3.1.101\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.

Build FAILED.

D:\a\1\s\FantasyLeague\FantasyLeague.csproj(345,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\3.1.101\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\3.1.101\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.47

就在管道中的此步骤之前,有一个恢复步骤应该恢复任何丢失的 NuGet 包,所以我不确定会发生什么,而且我是 Azure 的新手。任何帮助我克服这个障碍的帮助将不胜感激。谢谢!

【问题讨论】:

  • 也许你的路径在构建管道中是错误的?
  • 嗨,您尝试过以下解决方案吗?这个案子的进展如何?

标签: asp.net-mvc azure azure-devops


【解决方案1】:

您可以尝试启用构建任务的Restore NuGet Packages 选项。

如果您使用的是经典 UI 管道。此选项位于构建任务的Advanced 设置中。

对于yaml管道,可以设置restoreNugetPackages: true

- task: VSBuild@1
  inputs:
    solution: '**\*.sln' 
    restoreNugetPackages: true

希望以上有所帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-20
    • 1970-01-01
    • 2020-02-24
    • 1970-01-01
    • 2011-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多