microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.47k stars 2.6k forks source link

[Question]: ##[error]Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1 #19504

Open jswapneswar opened 7 months ago

jswapneswar commented 7 months ago

Task name

Dotnet Build

Task version

.*2

Environment type (Please select at least one enviroment where you face this issue)

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

Azure devops

Operation system

Windwos 2019 , latest

Question

In Build Part getting this errors ##[error]Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1

##[error]Dotnet command failed with non-zero exit code on the following projects : [ 'D:\\a\\1\\s\\src\\Integrations.Services.Configuration.API' ] 

Please help to resolve the issue
jswapneswar commented 7 months ago

Screenshot_1 Adding screenshots here for reference.

DenisRumyantsev commented 7 months ago

Hi @jswapneswar, can you please provide steps to reproduce your issue? Do you use YML pipelines? If so, can you share the yml file of your pipeline?

I see the MSBuild error on the screenshot, MSBUILD : error MSB1008: Only one project can be specified. So, can you please share the full command line?

jswapneswar commented 7 months ago

No, I used classic editor to create this CI, and this repo has one solution file and multiple csprojs. but I want to build one project out of all. So, when I try to build and it doesn't work, I'll send you a screenshot of the steps that I took. is it ok for you ?

jswapneswar commented 7 months ago

Net Build Dotnet Restore Dotnet SDK 7 0 install

First, I tried to install it. Net 7.0.x to build and run, and then restore and then build. In build, I am getting this issue, and I don't know how to solve it.

DenisRumyantsev commented 7 months ago

@jswapneswar can you please also enable debug logs (by setting system.debug pipeline variable to true) and share debug logs for the Build pipeline step (as text, not a screenshot)?

jswapneswar commented 7 months ago

Hi @DenisRumyantsev here are the debug logs for build step as you asked . Thank you

[debug]matchOptions.nocase: 'true'

[debug]matchOptions.nonull: 'false'

[debug]matchOptions.matchBase: 'false'

[debug]matchOptions.nocomment: 'false'

[debug]matchOptions.nonegate: 'false'

[debug]matchOptions.flipNegate: 'false'

[debug]pattern: 'src/Integrations.Services.Configuration.API'

[debug]findPath: 'D:\a\1\s\src\Integrations.Services.Configuration.API'

[debug]statOnly: 'true'

[debug]found 1 paths

[debug]applying include pattern

[debug]adjustedPattern: 'D:\a\1\s\src/Integrations.Services.Configuration.API'

[debug]1 matches

[debug]1 final results

[debug]which 'C:\hostedtoolcache\windows\dotnet\dotnet.exe'

[debug]found: 'C:\hostedtoolcache\windows\dotnet\dotnet.exe'

[debug]C:\hostedtoolcache\windows\dotnet\dotnet.exe arg: build

[debug]C:\hostedtoolcache\windows\dotnet\dotnet.exe arg: D:\a\1\s\src\Integrations.Services.Configuration.API

[debug]C:\hostedtoolcache\windows\dotnet\dotnet.exe arg: -dl:CentralLogger,"D:\a_tasks\DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b\2.235.0\dotnet-build-helpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"*ForwardingLogger,"D:\a_tasks\DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b\2.235.0\dotnet-build-helpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"

[debug]C:\hostedtoolcache\windows\dotnet\dotnet.exe arg: --project $ (BuildConfiguration)

[debug]exec tool: C:\hostedtoolcache\windows\dotnet\dotnet.exe

[debug]arguments:

[debug] build

[debug] D:\a\1\s\src\Integrations.Services.Configuration.API

[debug] -dl:CentralLogger,"D:\a_tasks\DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b\2.235.0\dotnet-build-helpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"*ForwardingLogger,"D:\a_tasks\DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b\2.235.0\dotnet-build-helpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"

[debug] --project

[debug] $

[debug] (BuildConfiguration)

C:\hostedtoolcache\windows\dotnet\dotnet.exe build D:\a\1\s\src\Integrations.Services.Configuration.API "-dl:CentralLogger,\"D:\a_tasks\DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b\2.235.0\dotnet-build-helpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll\"ForwardingLogger,\"D:\a_tasks\DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b\2.235.0\dotnet-build-helpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll\"" --project $ (BuildConfiguration) MSBuild version 17.7.4+3ebbd7c49 for .NET MSBUILD : error MSB1001: Unknown switch. Full command line: 'C:\hostedtoolcache\windows\dotnet\sdk\7.0.405\MSBuild.dll -maxcpucount -verbosity:m -restore -consoleloggerparameters:Summary D:\a\1\s\src\Integrations.Services.Configuration.API -dl:CentralLogger,"D:\a_tasks\DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b\2.235.0\dotnet-build-helpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"ForwardingLogger,"D:\a_tasks\DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b\2.235.0\dotnet-build-helpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" --project $ (BuildConfiguration) -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\hostedtoolcache\windows\dotnet\sdk\7.0.405\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\hostedtoolcache\windows\dotnet\sdk\7.0.405\dotnet.dll' Switches appended by response files: Switch: --project

For switch syntax, type "MSBuild -help"

[debug]Exit code 1 received from tool 'C:\hostedtoolcache\windows\dotnet\dotnet.exe'

[debug]STDIO streams have closed for tool 'C:\hostedtoolcache\windows\dotnet\dotnet.exe'

[error]Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1

[debug]Processed: ##vso[task.issue type=error;]Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1

[warning].NET 5 has some compatibility issues with older Nuget versions(<=5.7), so if you are using an older Nuget version(and not dotnet cli) to restore, then the dotnet cli commands (e.g. dotnet build) which rely on such restored packages might fail. To mitigate such error, you can either: (1) - Use dotnet cli to restore, (2) - Use Nuget version 5.8 to restore, (3) - Use global.json using an older sdk version(<=3) to build

[debug]Processed: ##vso[task.issue type=warning;].NET 5 has some compatibility issues with older Nuget versions(<=5.7), so if you are using an older Nuget version(and not dotnet cli) to restore, then the dotnet cli commands (e.g. dotnet build) which rely on such restored packages might fail. To mitigate such error, you can either: (1) - Use dotnet cli to restore, (2) - Use Nuget version 5.8 to restore, (3) - Use global.json using an older sdk version(<=3) to build

Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://docs.microsoft.com/en-us/dotnet/core/tools/ and https://docs.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting

[debug]task result: Failed

[error]Dotnet command failed with non-zero exit code on the following projects : [ 'D:\a\1\s\src\Integrations.Services.Configuration.API' ]

[debug]Processed: ##vso[task.issue type=error;]Dotnet command failed with non-zero exit code on the following projects : [ 'D:\a\1\s\src\Integrations.Services.Configuration.API' ]

[debug]Processed: ##vso[task.complete result=Failed;]Dotnet command failed with non-zero exit code on the following projects : [ 'D:\a\1\s\src\Integrations.Services.Configuration.API' ]

Finishing: Build

jswapneswar commented 7 months ago

Hi @DenisRumyantsev I got to know that it was using a different SDK runtime version to build this project. I added perform multilookup to true, but it was installing the 7.X version. While building,but it was taking the 5.X version. So how do I lock or provide the correct version to build this project? I enabled global. json also, but it's not in my project. Is there any other way to restrict the versions?

jswapneswar commented 7 months ago

Hi @DenisRumyantsev any luck ?

NdirituGichu commented 3 months ago

Hello, I encountered a similar issue. It seems that the target framework in my .csproj was not matching what I had specified to in my yaml file. Upon changing them to a similar framework, the build and tests ran to completion. Try changing matching them and see if the build is successful.

Hi @DenisRumyantsev I got to know that it was using a different SDK runtime version to build this project. I added perform multilookup to true, but it was installing the 7.X version. While building,but it was taking the 5.X version. So how do I lock or provide the correct version to build this project? I enabled global. json also, but it's not in my project. Is there any other way to restrict the versions?