microsoft / azure-pipelines-tasks

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

[BUG]: MSBuild task fails after msbuild.exe exits with exit code '' (empty string) #19781

Open andersforsgren opened 5 months ago

andersforsgren commented 5 months ago

New issue checklist

Task name

MsBuild

Task version

1.231.5

Issue Description

After a successful compilation (the output assembly is produced OK and no errors or warnings are logged), the task fails and outputs the message

[error]Process 'msbuild.exe' exited with code ''.

This happens intermittently and is hard to diagnose as there is no error output. It does not reproduce on a different machine or with a simple repro. What can I do to find this? In what situation would a process not set the exit code? I have looked through the windows event log to see any messages from msbuild.exe but that shows nothing.

Task configuration:

   - task: MSBuild@1
     displayName: 'Compile ProjectName'
     inputs:
       solution: '$(Build.Repository.LocalPath)/Source/ProjectName/ProjectName.csproj'
       platform: '$(buildPlatform)'
       configuration: '$(buildConfiguration)'
       msbuildArguments: '/v:m /t:Restore;Build'

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)

No response

Operation system

Windows 10

Relevant log output

##[error]Process 'msbuild.exe' exited with code ''.

Full task logs with system.debug enabled

2024-04-16T08:32:38.1596881Z ##[debug]Evaluating condition for step: 'Compile ProjectName.dll'
2024-04-16T08:32:38.1597653Z ##[debug]Evaluating: SucceededNode()
2024-04-16T08:32:38.1597887Z ##[debug]Evaluating SucceededNode:
2024-04-16T08:32:38.1598233Z ##[debug]=> True
2024-04-16T08:32:38.1598445Z ##[debug]Result: True
2024-04-16T08:32:38.1598689Z ##[section]Starting: Compile ProjectName.dll
2024-04-16T08:32:38.1817772Z ==============================================================================
2024-04-16T08:32:38.1818132Z Task         : MSBuild
2024-04-16T08:32:38.1818204Z Description  : Build with MSBuild
2024-04-16T08:32:38.1818308Z Version      : 1.231.5
2024-04-16T08:32:38.1818376Z Author       : Microsoft Corporation
2024-04-16T08:32:38.1818493Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/msbuild
2024-04-16T08:32:38.1818734Z ==============================================================================
2024-04-16T08:32:39.9117731Z ##[debug]VstsTaskSdk 0.17.0 commit b31a83bf175a3768b346a9def8d95d60f238f089
2024-04-16T08:32:40.0896768Z ##[debug]Entering C:\TfsAgent\1\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\MSBuild.ps1.
2024-04-16T08:32:40.0996553Z ##[debug]Loading module from path 'C:\TfsAgent\1\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\node_modules\azure-pipelines-tasks-msbuildhelpers\MSBuildHelpers.psm1'.
2024-04-16T08:32:40.1164865Z ##[debug]Loading resource strings from: C:\TfsAgent\1\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\node_modules\azure-pipelines-tasks-msbuildhelpers\module.json
2024-04-16T08:32:40.1314290Z ##[debug]Loaded 9 strings.
2024-04-16T08:32:40.1347451Z ##[debug]SYSTEM_CULTURE: 'en-US'
2024-04-16T08:32:40.1376560Z ##[debug]Loading resource strings from: C:\TfsAgent\1\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\node_modules\azure-pipelines-tasks-msbuildhelpers\Strings\resources.resjson\en-US\resources.resjson
2024-04-16T08:32:40.1507819Z ##[debug]Loaded 9 strings.
2024-04-16T08:32:40.2602087Z ##[debug]Exporting function 'Format-MSBuildArguments'.
2024-04-16T08:32:40.2618186Z ##[debug]Exporting function 'Invoke-BuildTools'.
2024-04-16T08:32:40.2634069Z ##[debug]Exporting function 'Get-MSBuildPath'.
2024-04-16T08:32:40.2649542Z ##[debug]Exporting function 'Get-SolutionFiles'.
2024-04-16T08:32:40.2664545Z ##[debug]Exporting function 'Get-VisualStudio'.
2024-04-16T08:32:40.2679548Z ##[debug]Exporting function 'Select-MSBuildPath'.
2024-04-16T08:32:40.2694496Z ##[debug]Exporting function 'EmitTelemetry'.
2024-04-16T08:32:40.2712169Z ##[debug]Importing function 'EmitTelemetry'.
2024-04-16T08:32:40.2727120Z ##[debug]Importing function 'Format-MSBuildArguments'.
2024-04-16T08:32:40.2742213Z ##[debug]Importing function 'Get-MSBuildPath'.
2024-04-16T08:32:40.2757596Z ##[debug]Importing function 'Get-SolutionFiles'.
2024-04-16T08:32:40.2773262Z ##[debug]Importing function 'Get-VisualStudio'.
2024-04-16T08:32:40.2788384Z ##[debug]Importing function 'Invoke-BuildTools'.
2024-04-16T08:32:40.2803826Z ##[debug]Importing function 'Select-MSBuildPath'.
2024-04-16T08:32:40.2823715Z ##[debug]Loading resource strings from: C:\TfsAgent\1\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\Task.json
2024-04-16T08:32:40.2915713Z ##[debug]Loaded 3 strings.
2024-04-16T08:32:40.2939560Z ##[debug]SYSTEM_CULTURE: 'en-US'
2024-04-16T08:32:40.2963168Z ##[debug]Loading resource strings from: C:\TfsAgent\1\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\Strings\resources.resjson\en-US\resources.resjson
2024-04-16T08:32:40.3023586Z ##[debug]Loaded 3 strings.
2024-04-16T08:32:40.3062642Z ##[debug]SYSTEM_DEBUG: 'True'
2024-04-16T08:32:40.3089088Z ##[debug] Converted to bool: True
2024-04-16T08:32:40.3232715Z ##[debug]INPUT_MSBUILDLOCATIONMETHOD: 'version'
2024-04-16T08:32:40.3255075Z ##[debug]INPUT_MSBUILDLOCATION (empty)
2024-04-16T08:32:40.3295403Z ##[debug]INPUT_MSBUILDARGUMENTS: '/v:m /t:Restore;Build'
2024-04-16T08:32:40.3325023Z ##[debug]INPUT_SOLUTION: 'C:\TfsAgent\1\_work\24\s\Source\Company.Product.ProjectName\Company.Product.ProjectName.csproj'
2024-04-16T08:32:40.3359045Z ##[debug]INPUT_PLATFORM: 'AnyCPU'
2024-04-16T08:32:40.3386818Z ##[debug]INPUT_CONFIGURATION: 'Release'
2024-04-16T08:32:40.3413269Z ##[debug]INPUT_CLEAN: 'false'
2024-04-16T08:32:40.3435884Z ##[debug] Converted to bool: False
2024-04-16T08:32:40.3465083Z ##[debug]INPUT_MAXIMUMCPUCOUNT: 'false'
2024-04-16T08:32:40.3488719Z ##[debug] Converted to bool: False
2024-04-16T08:32:40.3514702Z ##[debug]INPUT_RESTORENUGETPACKAGES: 'false'
2024-04-16T08:32:40.3533506Z ##[debug] Converted to bool: False
2024-04-16T08:32:40.3558428Z ##[debug]INPUT_LOGPROJECTEVENTS: 'false'
2024-04-16T08:32:40.3579150Z ##[debug] Converted to bool: False
2024-04-16T08:32:40.3604504Z ##[debug]INPUT_CREATELOGFILE: 'false'
2024-04-16T08:32:40.3624081Z ##[debug] Converted to bool: False
2024-04-16T08:32:40.3650267Z ##[debug]INPUT_MSBUILDVERSION: 'latest'
2024-04-16T08:32:40.3673500Z ##[debug]INPUT_MSBUILDARCHITECTURE: 'x86'
2024-04-16T08:32:40.3779964Z ##[debug]Entering Get-SolutionFiles.
2024-04-16T08:32:40.3865689Z ##[debug] Solution: 'C:\TfsAgent\1\_work\24\s\Source\Company.Product.ProjectName\Company.Product.ProjectName.csproj'
2024-04-16T08:32:40.3896679Z ##[debug]Leaving Get-SolutionFiles.
2024-04-16T08:32:40.3971337Z ##[debug]Entering Format-MSBuildArguments.
2024-04-16T08:32:40.3988705Z ##[debug] MSBuildArguments: '/v:m /t:Restore;Build'
2024-04-16T08:32:40.4005478Z ##[debug] Platform: 'AnyCPU'
2024-04-16T08:32:40.4021934Z ##[debug] Configuration: 'Release'
2024-04-16T08:32:40.4054885Z ##[debug] MaximumCpuCount: 'False'
2024-04-16T08:32:40.4163907Z ##[debug]AZURE_HTTP_USER_AGENT: 'VSTS_0fb8c2fd-105a-40af-b84d-cd5bc19dc76d_build_98_0'
2024-04-16T08:32:40.4184633Z ##[debug]Leaving Format-MSBuildArguments.
2024-04-16T08:32:40.4232030Z ##[debug]Entering Select-MSBuildPath.
2024-04-16T08:32:40.4251344Z ##[debug] Method: 'version'
2024-04-16T08:32:40.4269344Z ##[debug] Location: ''
2024-04-16T08:32:40.4286477Z ##[debug] PreferredVersion: 'latest'
2024-04-16T08:32:40.4303408Z ##[debug] Architecture: 'x86'
2024-04-16T08:32:40.4624577Z ##[debug]Entering Get-MSBuildPath.
2024-04-16T08:32:40.4643378Z ##[debug] Version: '17.0'
2024-04-16T08:32:40.4660423Z ##[debug] Architecture: 'x86'
2024-04-16T08:32:40.4726501Z ##[debug]Entering Get-VisualStudio.
2024-04-16T08:32:40.4743359Z ##[debug] MajorVersion: '17'
2024-04-16T08:32:40.4769820Z ##[debug]Getting latest Visual Studio 17 setup instance.
2024-04-16T08:32:40.4877962Z ##[debug]Entering Invoke-VstsTool.
2024-04-16T08:32:40.4897540Z ##[debug] FileName: 'C:\TfsAgent\1\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\node_modules\azure-pipelines-tasks-msbuildhelpers\tools\vswhere.exe'
2024-04-16T08:32:40.4914270Z ##[debug] Arguments: '-version [17.0,18.0) -latest -format json'
2024-04-16T08:32:40.4930667Z ##[debug] RequireExitCodeZero: 'True'
2024-04-16T08:32:40.4948761Z ##[command]"C:\TfsAgent\1\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\node_modules\azure-pipelines-tasks-msbuildhelpers\tools\vswhere.exe" -version [17.0,18.0) -latest -format json
2024-04-16T08:32:40.5663042Z ##[debug][
2024-04-16T08:32:40.5696653Z ##[debug]  {
2024-04-16T08:32:40.5713191Z ##[debug]    "instanceId": "784b5686",
2024-04-16T08:32:40.5730730Z ##[debug]    "installDate": "2023-02-23T13:44:07Z",
2024-04-16T08:32:40.5750126Z ##[debug]    "installationName": "VisualStudio/17.5.0+33414.496",
2024-04-16T08:32:40.5770709Z ##[debug]    "installationPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise",
2024-04-16T08:32:40.5788060Z ##[debug]    "installationVersion": "17.5.33414.496",
2024-04-16T08:32:40.5804691Z ##[debug]    "displayName": "Visual Studio Enterprise 2022",
2024-04-16T08:32:40.5822043Z ##[debug]    "description": "Scalable, end-to-end solution for teams of any size",
2024-04-16T08:32:40.5839103Z ##[debug]    "updateDate": "2023-02-23T13:44:07.2505138Z",
2024-04-16T08:32:40.5857153Z ##[debug]    "enginePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\resources\\app\\ServiceHub\\Services\\Microsoft.VisualStudio.Setup.Service",
2024-04-16T08:32:40.5874678Z ##[debug]    "resolvedInstallationPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise",
2024-04-16T08:32:40.5892411Z ##[debug]    "channelId": "VisualStudio.17.Release",
2024-04-16T08:32:40.5909674Z ##[debug]    "installedChannelId": "VisualStudio.17.Release",
2024-04-16T08:32:40.5928734Z ##[debug]    "channelUri": "https://aka.ms/vs/17/release/channel",
2024-04-16T08:32:40.5945469Z ##[debug]    "installedChannelUri": "https://aka.ms/vs/17/release/channel",
2024-04-16T08:32:40.5963387Z ##[debug]    "releaseNotes": "https://docs.microsoft.com/en-us/visualstudio/releases/2022/release-notes-v17.5#17.5.0",
2024-04-16T08:32:40.5980406Z ##[debug]    "thirdPartyNotices": "https://go.microsoft.com/fwlink/?LinkId=661288"
2024-04-16T08:32:40.5997247Z ##[debug]  }
2024-04-16T08:32:40.6013622Z ##[debug]]
2024-04-16T08:32:40.6034386Z ##[debug]Exit code: 0
2024-04-16T08:32:40.6054036Z ##[debug]Leaving Invoke-VstsTool.
2024-04-16T08:32:40.6282744Z ##[debug]Leaving Get-VisualStudio.
2024-04-16T08:32:40.6314628Z ##[debug]Loading C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Microsoft.Build.Utilities.Core.dll
2024-04-16T08:32:40.6744302Z ##[debug]MSBuild: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\msbuild.exe
2024-04-16T08:32:40.6763662Z ##[debug]Leaving Get-MSBuildPath.
2024-04-16T08:32:40.6780570Z ##[debug]Leaving Select-MSBuildPath.
2024-04-16T08:32:40.6868230Z ##[debug]Entering Invoke-BuildTools.
2024-04-16T08:32:40.6884276Z ##[debug] NuGetRestore: 'False'
2024-04-16T08:32:40.6899050Z ##[debug] SolutionFiles: 'C:\TfsAgent\1\_work\24\s\Source\Company.Product.ProjectName\Company.Product.ProjectName.csproj'
2024-04-16T08:32:40.6913730Z ##[debug] MSBuildLocation: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\msbuild.exe'
2024-04-16T08:32:40.6928519Z ##[debug] MSBuildArguments: '/v:m /t:Restore;Build /p:platform="AnyCPU" /p:configuration="Release" /p:_MSDeployUserAgent="VSTS_0fb8c2fd-105a-40af-b84d-cd5bc19dc76d_build_98_0"'
2024-04-16T08:32:40.6942698Z ##[debug] Clean: 'False'
2024-04-16T08:32:40.6957126Z ##[debug] NoTimelineLogger: 'True'
2024-04-16T08:32:40.6971762Z ##[debug] CreateLogFile: 'False'
2024-04-16T08:32:40.6986963Z ##[debug] LogFileVerbosity: 'diagnostic'
2024-04-16T08:32:40.7139168Z ##[debug]Entering Invoke-MSBuild.
2024-04-16T08:32:40.7154493Z ##[debug] ProjectFile: 'C:\TfsAgent\1\_work\24\s\Source\Company.Product.ProjectName\Company.Product.ProjectName.csproj'
2024-04-16T08:32:40.7169388Z ##[debug] MSBuildPath: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\msbuild.exe'
2024-04-16T08:32:40.7185275Z ##[debug] AdditionalArguments: '/v:m /t:Restore;Build /p:platform="AnyCPU" /p:configuration="Release" /p:_MSDeployUserAgent="VSTS_0fb8c2fd-105a-40af-b84d-cd5bc19dc76d_build_98_0"'
2024-04-16T08:32:40.7199611Z ##[debug] NoTimelineLogger: 'True'
2024-04-16T08:32:40.7214424Z ##[debug] IsDefaultLoggerEnabled: 'True'
2024-04-16T08:32:40.7229125Z ##[debug] LogFileVerbosity: 'diagnostic'
2024-04-16T08:32:40.7323725Z ##[debug]Asserting leaf path exists: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\msbuild.exe'
2024-04-16T08:32:40.7347653Z ##[debug]Asserting leaf path exists: 'C:\TfsAgent\1\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\node_modules\azure-pipelines-tasks-msbuildhelpers\tools\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll'
2024-04-16T08:32:40.7438356Z ##[debug]Should use Invoke-VstsProcess: True
2024-04-16T08:32:40.7505466Z ##[debug]Entering Invoke-VstsProcess.
2024-04-16T08:32:40.7520634Z ##[debug] FileName: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\msbuild.exe'
2024-04-16T08:32:40.7538153Z ##[debug] Arguments: '"C:\TfsAgent\1\_work\24\s\Source\Company.Product.ProjectName\Company.Product.ProjectName.csproj" /nologo /nr:false /dl:CentralLogger,"C:\TfsAgent\1\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\node_modules\azure-pipelines-tasks-msbuildhelpers\tools\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=|SolutionDir=C:\TfsAgent\1\_work\24\s\Source\Company.Product.ProjectName|enableOrphanedProjectsLogs=true"*ForwardingLogger,"C:\TfsAgent\1\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\node_modules\azure-pipelines-tasks-msbuildhelpers\tools\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /v:m /t:Restore;Build /p:platform="AnyCPU" /p:configuration="Release" /p:_MSDeployUserAgent="VSTS_0fb8c2fd-105a-40af-b84d-cd5bc19dc76d_build_98_0"'
2024-04-16T08:32:40.7550118Z ##[debug] RequireExitCodeZero: 'True'
2024-04-16T08:32:40.7560282Z ##[command]"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\msbuild.exe" "C:\TfsAgent\1\_work\24\s\Source\Company.Product.ProjectName\Company.Product.ProjectName.csproj" /nologo /nr:false /dl:CentralLogger,"C:\TfsAgent\1\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\node_modules\azure-pipelines-tasks-msbuildhelpers\tools\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=|SolutionDir=C:\TfsAgent\1\_work\24\s\Source\Company.Product.ProjectName|enableOrphanedProjectsLogs=true"*ForwardingLogger,"C:\TfsAgent\1\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\node_modules\azure-pipelines-tasks-msbuildhelpers\tools\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /v:m /t:Restore;Build /p:platform="AnyCPU" /p:configuration="Release" /p:_MSDeployUserAgent="VSTS_0fb8c2fd-105a-40af-b84d-cd5bc19dc76d_build_98_0"
2024-04-16T08:32:41.1410094Z 
2024-04-16T08:32:41.9525084Z   Determining projects to restore...
2024-04-16T08:32:42.6332105Z   Restored C:\TfsAgent\1\_work\24\s\Source\Company.Product.ProjectName\Company.Product.ProjectName.csproj (in 415 ms).
2024-04-16T08:32:49.1508393Z   Company.Product.ProjectName -> C:\TfsAgent\1\_work\24\s\Source\bin\AnyCPU\Release\Company.Product.ProjectName.dll
2024-04-16T08:32:49.1580366Z   C:\TfsAgent\1\_work\24\s\Source\bin\AnyCPU\Release\Company.Product.ProjectName.dll -> C:\TfsAgent\1\_work\24\s\Source\bin\AnyCPU\Release\ProjectName.dat
2024-04-16T08:32:49.2027341Z ##[debug]Exit code: 
2024-04-16T08:32:49.2144967Z ##[debug]Error record:
2024-04-16T08:32:49.3224952Z ##[debug]Invoke-VstsProcess : Process 'msbuild.exe' exited with code ''.
2024-04-16T08:32:49.3234166Z ##[debug]At C:\TfsAgent\1\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\node_modules\azure-pipelines-tasks-msbuildhelpers\InvokeFunctions.ps1:126 char:17
2024-04-16T08:32:49.3243136Z ##[debug]+ ...             Invoke-VstsProcess -FileName $MSBuildPath -Arguments $arg ...
2024-04-16T08:32:49.3252724Z ##[debug]+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2024-04-16T08:32:49.3262112Z ##[debug]    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
2024-04-16T08:32:49.3272187Z ##[debug]    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-VstsProcess
2024-04-16T08:32:49.3281741Z ##[debug] 
2024-04-16T08:32:49.3298250Z ##[debug]Script stack trace:
2024-04-16T08:32:49.3324523Z ##[debug]at Invoke-Process, C:\TfsAgent\1\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\ps_modules\VstsTaskSdk\ToolFunctions.ps1: line 217
2024-04-16T08:32:49.3334388Z ##[debug]at Invoke-MSBuild, C:\TfsAgent\1\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\node_modules\azure-pipelines-tasks-msbuildhelpers\InvokeFunctions.ps1: line 126
2024-04-16T08:32:49.3343831Z ##[debug]at Invoke-BuildTools, C:\TfsAgent\1\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\node_modules\azure-pipelines-tasks-msbuildhelpers\InvokeFunctions.ps1: line 42
2024-04-16T08:32:49.3353119Z ##[debug]at , C:\TfsAgent\1\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\MSBuild.ps1: line 63
2024-04-16T08:32:49.3362313Z ##[debug]at , : line 1
2024-04-16T08:32:49.3371741Z ##[debug]at , : line 22
2024-04-16T08:32:49.3381011Z ##[debug]at , : line 18
2024-04-16T08:32:49.3390390Z ##[debug]at , : line 1
2024-04-16T08:32:49.3406543Z ##[debug]Exception:
2024-04-16T08:32:49.3435285Z ##[debug]Microsoft.PowerShell.Commands.WriteErrorException: Process 'msbuild.exe' exited with code ''.
2024-04-16T08:32:49.3577735Z ##[error]Process 'msbuild.exe' exited with code ''.
2024-04-16T08:32:49.3582337Z ##[debug]Processed: ##vso[task.logissue type=error]Process 'msbuild.exe' exited with code ''.
2024-04-16T08:32:49.3584224Z ##[debug]Leaving Invoke-VstsProcess.
2024-04-16T08:32:49.3627123Z ##[debug]Processed: ##vso[task.complete result=Failed]
2024-04-16T08:32:49.3643960Z ##[debug]Leaving Invoke-MSBuild.
2024-04-16T08:32:49.3660616Z ##[debug]Leaving Invoke-BuildTools.
2024-04-16T08:32:49.3783117Z ##[debug]AGENT_VERSION: '3.230.0'
2024-04-16T08:32:49.4234503Z ##[debug]Processed: ##vso[telemetry.publish area=TaskHub;feature=MSBuildV1]{"MSBuildVersion":"latest","MSBuildLocationMethod":"version","Platform":"AnyCPU","Configuration":"Release","MSBuildExecutionTimeSeconds":8.687}
2024-04-16T08:32:49.4236109Z ##[debug]Leaving C:\TfsAgent\1\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\MSBuild.ps1.
2024-04-16T08:32:49.4277703Z ##[section]Finishing: Compile ProjectName.dll

Repro steps

No response

andersforsgren commented 1 month ago

This happens still,

Current agent version: '3.239.1'
...
##[error]Process 'msbuild.exe' exited with code ''.

Assuming this happens in azure-pipelines-tasks-lib (ToolFunctions.ps1):

Tasks/MSBuildV1/msbuild.ts

        Write-Verbose "Exit code: $LASTEXITCODE"
        if ($RequireExitCodeZero -and $LASTEXITCODE -ne 0) {
            Write-Error (Get-LocString -Key PSLIB_Process0ExitedWithCode1 -ArgumentList ([System.IO.Path]::GetFileName($FileName)), $LASTEXITCODE)
        }

Is $LASTEXITCODE being unset really properly handled here?

When the process fails, the last project compiled looks like this with diagnostics on:

  MyAssembly -> C:\TfsAgent\2\_work\1\b\MyAssembly.dll
##[debug]Processed: ##vso[task.logdetail id=a2d0fbce-2ff3-4051-933a-1b6bf83d692e;parentid=2f9f376e-54a7-4e8a-9111-009e62b62380;type=Build;result=Succeeded;finishtime=2024-08-06T12:59:55.6167709Z;progress=100;state=Completed;parentid=2f9f376e-54a7-4e8a-9111-009e62b62380;name=;]
##[debug]Processed: ##vso[task.logdetail id=2f9f376e-54a7-4e8a-9111-009e62b62380;parentid=6ebdce3e-7521-4440-9e33-5777f1abc1a5;type=Build;result=Succeeded;finishtime=2024-08-06T12:59:55.6167709Z;progress=100;state=Completed;parentid=6ebdce3e-7521-4440-9e33-5777f1abc1a5;name=;]
##[debug]Exit code: 
##[debug]Error record:
##[debug]Invoke-VstsProcess : Process 'msbuild.exe' exited with code ''.
##[debug]At C:\TfsAgent\2\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.231.0\node_modules\azure-pipelines-tasks-msbuildhelpers\InvokeFunctions.ps1:126 char:17
##[debug]+ ...             Invoke-VstsProcess -FileName $MSBuildPath -Arguments $arg ...
##[debug]+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
##[debug]    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
##[debug]    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-VstsProcess
##[debug] 
##[debug]Script stack trace:
##[debug]at Invoke-Process, C:\TfsAgent\2\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.231.0\ps_modules\VstsTaskSdk\ToolFunctions.ps1: line 217
##[debug]at Invoke-MSBuild, C:\TfsAgent\2\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.231.0\node_modules\azure-pipelines-tasks-msbuildhelpers\InvokeFunctions.ps1: line 126
##[debug]at Invoke-BuildTools, C:\TfsAgent\2\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.231.0\node_modules\azure-pipelines-tasks-msbuildhelpers\InvokeFunctions.ps1: line 42
##[debug]at <ScriptBlock>, C:\TfsAgent\2\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.231.0\VSBuild.ps1: line 103
##[debug]at <ScriptBlock>, <No file>: line 1
##[debug]at <ScriptBlock>, <No file>: line 22
##[debug]at <ScriptBlock>, <No file>: line 18
##[debug]at <ScriptBlock>, <No file>: line 1
##[debug]Exception:
##[debug]Microsoft.PowerShell.Commands.WriteErrorException: Process 'msbuild.exe' exited with code ''.
##[error]Process 'msbuild.exe' exited with code ''.
##[debug]Processed: ##vso[task.logissue type=error]Process 'msbuild.exe' exited with code ''.
##[debug]Leaving Invoke-VstsProcess.
##[debug]Processed: ##vso[task.complete result=Failed]
##[debug]Processed: ##vso[task.logdetail finishtime=2024-08-06T12:59:55.8198861Z;id=6ebdce3e-7521-4440-9e33-5777f1abc1a5;progress=100;state=Completed;result=Failed]
##[debug]Leaving Invoke-MSBuild.
##[debug]Leaving Invoke-BuildTools.
##[debug]AGENT_VERSION: '3.239.1'
chrisfcarroll commented 1 week ago

Could this be something that only happens on self-hosted agents?

I'm using self-hosted agents, and it looks to me that OP is too.

chrisfcarroll commented 1 week ago

@DenisRumyantsev , @v-schhabra : my apologies for @-ing you but it looks like this has been triaged into Azure:Artifacts by a bot, where it is receiving no attention perhaps because it is not related to artifacts ?

v-schhabra commented 1 week ago

Hi @chrisfcarroll Msbuild task is owned by ABTT team. I just tagged them here. I hope they will get notify now about this issue. image