Unable to build my old project in AzureDevops where as same application able to do in Visual Studio 2017 (with local library).
what is wrong here?
Reference code of 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)'
reference error
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'.
Need help in how to refer the local library folder
library folder structure
Project
--lib
The Microsoft-hosted agent "
windows-latest" hosts on the VM image that is Windows Server 2022 with Visual Studio 2022, and .NET 8 is the default .NET Core tool. The pre-installed .NET Core tools on this agent are listed here.And here is the list of .NET tools supported in Visual Studio 2017.
They are different versions and might have compatibility issues. If you directly move you project from VS 2017 to VS 2022, the issue could occur.
What you can try is one of the ways below:
Set up a self-hosted agent on your local machine which has VS 2017 installed. Then use this self-hosted agent to run the build in pipeline.
Upgrade the VS to 2022 on your local machine. Then open the project in VS 2022 and try to upgrade it to be compatible with VS 2022.