DevOps 中的构建失败

问题描述 投票:0回答:1

无法在 AzureDevops 中构建我的旧项目,而同一应用程序可以在 Visual Studio 2017 中构建。(使用本地库)

请帮助这里出了什么问题。

Azure DevOps参考代码

trigger:
- '*'

pool:
  vmImage: 'windows-latest'

variables:
  solution: 'sample.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '$(solution)'

- task: DotNetCoreCLI@2
  displayName: 'Build'
  inputs:
    command: 'build'
    projects: '$(solution)'
    arguments: '--configuration $(buildConfiguration)'

参考错误

2024-02-02T02:10:47.7732119Z ##[section]Starting: Build
2024-02-02T02:10:47.7931230Z ==============================================================================
2024-02-02T02:10:47.7931376Z Task         : .NET Core
2024-02-02T02:10:47.7931434Z Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command
2024-02-02T02:10:47.7931571Z Version      : 2.232.0
2024-02-02T02:10:47.7931626Z Author       : Microsoft Corporation
2024-02-02T02:10:47.7931692Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
2024-02-02T02:10:47.7931947Z ==============================================================================
2024-02-02T02:10:48.4107299Z [command]C:\Windows\system32\chcp.com 65001
2024-02-02T02:10:48.4245145Z Active code page: 65001
2024-02-02T02:10:48.4465706Z Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
2024-02-02T02:10:48.4530744Z [command]"C:\Program Files\dotnet\dotnet.exe" build D:\a\1\s\sample.sln "-dl:CentralLogger,\"D:\a\_tasks\DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b\2.232.0\dotnet-build-helpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll\"*ForwardingLogger,\"D:\a\_tasks\DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b\2.232.0\dotnet-build-helpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll\"" --configuration Release
2024-02-02T02:11:04.3361915Z MSBuild version 17.8.3+195e7f5a3 for .NET
2024-02-02T02:11:24.8320753Z   Determining projects to restore...
2024-02-02T02:11:26.5244033Z   Nothing to do. None of the projects specified contain packages to restore.
2024-02-02T02:11:26.8815385Z ##[error]MvcCms.Web\MvcCms.Web.csproj(8624,3): Error MSB4019: The imported project "C:\Program Files\dotnet\sdk\8.0.101\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\8.0.101\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.
2024-02-02T02:11:26.8860207Z D:\a\1\s\MvcCms.Web\MvcCms.Web.csproj(8624,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\8.0.101\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\8.0.101\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.
2024-02-02T02:11:29.1967373Z   Restoring NuGet packages...
2024-02-02T02:11:29.1972493Z   To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages'.
2024-02-02T02:11:29.1979109Z   Restoring NuGet packages...
2024-02-02T02:11:29.1980977Z   To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages'.
2024-02-02T02:11:31.1170019Z ##[error].nuget\NuGet.targets(100,9): Error : Unable to find version '4.2.1' of package 'AutoMapper'.
2024-02-02T02:11:31.1195420Z D:\a\1\s\.nuget\NuGet.targets(100,9): error : Unable to find version '4.2.1' of package 'AutoMapper'.

需要有关如何引用本地库文件夹的帮助

库文件夹结构

项目 --lib

感谢您的时间和帮助

我正在尝试构建应用程序,但失败了

azure-devops azure-pipelines nuget-package-restore
1个回答
0
投票

Microsoft 托管的代理“

windows-latest
”托管在虚拟机映像上,该映像是 Windows Server 2022 和 Visual Studio 2022,.NET 8 是默认的 .NET Core 工具。 此处列出了此代理上预安装的 .NET Core 工具。

此处是 Visual Studio 2017 支持的 .NET 工具列表。

它们是不同的版本,可能存在兼容性问题。如果您直接将项目从 VS 2017 移至 VS 2022,可能会出现此问题。


您可以尝试以下方法之一:

  1. 在安装了 VS 2017 的本地计算机上设置自托管代理。然后使用这个自托管代理来运行管道中的构建。

  2. 在本地计算机上将 VS 升级到 2022。然后在 VS 2022 中打开项目并尝试升级以兼容 VS 2022。


© www.soinside.com 2019 - 2024. All rights reserved.