microsoft / azure-pipelines-tasks

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

[REGRESSION]: DotNetCoreCLI@2 fails to run tests for x86 projects #19326

Closed fredrikloch closed 6 months ago

fredrikloch commented 11 months ago

New issue checklist

Task name

DotNetCoreCLI@2

Breaking task version

No response

Last working task version

No response

Regression Description

Description: This has been an issue since Monday 20nd November. DotNet test runs fail for a projects with an error message stating that Microsoft.WindowsDesktop.App (net core 6) is missing on windows-latest, self-hosted and VMSS agents.

This issue was raised here: https://github.com/actions/runner-images/issues/8859 (reported as an Azure devops issue), but was closed with a claim that it is not image related, and it was recommended to raise the issue here. I'm hoping this is the right place to raise this! If I should raise this elsewhere, please let me know and feel free to close this.

We see no change in version between failing and successful runs, our current workaround is to run a self hosted agent where we've manually installed dotnet desktop sdk.

To trigger the issue, we've used the following csproj settings: "Code project"

  <PropertyGroup>
    <TargetFramework>net6.0-windows</TargetFramework>
    <UseWPF>true</UseWPF>
    <Platforms>x86</Platforms>
    <Configurations>Debug;Release</Configurations>
    <Nullable>enable</Nullable>
    <IsPackable>false</IsPackable>
    <implicitUsings>enable</implicitUsings>
  </PropertyGroup>

"Test project"

  <PropertyGroup>
    <TargetFramework>net6.0-windows</TargetFramework>
    <Platforms>x86</Platforms>
    <Configurations>Debug;Release</Configurations>
    <Nullable>enable</Nullable>
    <ImplicitUsings>true</ImplicitUsings>
  </PropertyGroup>

msbuild.zip for failing 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 11, Windows Server 2022

Relevant log output

Testhost process for source(s) 'D:\a\1\s\tests\HWST.Core.Modules.UI.WPF.Tests\bin\x86\Debug\net6.0-windows\HWST.Core.Modules.UI.WPF.Tests.dll' exited with error: You must install or update .NET to run this application.
App: D:\a\1\s\tests\HWST.Core.Modules.UI.WPF.Tests\bin\x86\Debug\net6.0-windows\testhost.x86.exe
Architecture: x86
Framework: 'Microsoft.WindowsDesktop.App', version '6.0.0' (x86)
.NET location: C:\Program Files (x86)\dotnet\
The following frameworks were found:
  8.0.0 at [C:\Program Files (x86)\dotnet\shared\Microsoft.WindowsDesktop.App]
Learn more:
https://aka.ms/dotnet/app-launch-failed
To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.WindowsDesktop.App&framework_version=6.0.0&arch=x86&rid=win-x86&os=win10
. Please check the diagnostic logs for more information.
Results File: D:\a\_temp\VssAdministrator_fv-az390-674_2023-11-28_09_16_39.trx

Full task logs with system.debug enabled

UNSUCCESSFUL RUN
              638367594927524576:   8       7        0.030s     11.437s 
             638367594927824204:   x       |        0.007s     11.443s 
             638367594927890416:   0       x        29.942s     41.386s +++++ (scale 1:100)
             638367595227428289:   9       x        0.004s     41.401s 
             638367595227468029:   10      11       0.054s     41.455s .
             638367595228009081:   12      |        0.028s     41.483s 
             638367595228289795:   |       x        0.432s     41.915s ........
             638367595232611391:   x       13       0.008s     41.923s 
             638367595232687687:   12      x        0.030s     41.953s 
             638367595232987416:   x       14       7.976s     49.929s + (scale 1:100)
             638367595312746784:   15      x        14.065s     63.994s ++ (scale 1:100)
             638367595453398342:   x       14       0.456s     64.450s .........
             638367595457961290:   12      x        0.002s     64.452s 
             638367595457979895:   x       16       0.002s     64.454s 
             638367595457996889:   12      x        0.564s     65.018s ...........
             638367595463637016:   x       17       0.006s     65.024s 
             638367595463699556:   12      x        0.135s     65.159s ..
             638367595465048576:   10      x        4.719s     69.878s ..............................................................................................
             638367595512234049:   9       x        0.001s     69.879s 
             -----------------------------------------------------------------------------------------------------------------------------------
             Utilization:          87.7    25.7     Average Utilization: 56.7
    ##[debug]Exit code 1 received from tool 'C:\hostedtoolcache\windows\dotnet\dotnet.exe'

    Build FAILED.
        0 Warning(s)
        0 Error(s)

    Time Elapsed 00:01:11.06
    ##[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
    ##[debug]BuildConfiguration=undefined
    ##[debug]BuildPlatform=undefined
    ##[debug]testRunTitle=undefined
    ##[debug]defaultRoot: 'D:\a\_temp'
    ##[debug]findOptions.allowBrokenSymbolicLinks: 'false'
    ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
    ##[debug]findOptions.followSymbolicLinks: 'true'
    ##[debug]findOptions.skipMissingFiles: 'false'
    ##[debug]matchOptions.debug: 'false'
    ##[debug]matchOptions.nobrace: 'true'
    ##[debug]matchOptions.noglobstar: 'false'
    ##[debug]matchOptions.dot: 'true'
    ##[debug]matchOptions.noext: 'false'
    ##[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: '**/*.trx'
    ##[debug]findPath: 'D:\a\_temp'
    ##[debug]statOnly: 'false'
    ##[debug]findPath: 'D:\a\_temp'
    ##[debug]findOptions.allowBrokenSymbolicLinks: 'false'
    ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
    ##[debug]findOptions.followSymbolicLinks: 'true'
    ##[debug]findOptions.skipMissingFiles: 'false'
    ##[debug]  D:\a\_temp (directory)
SUCCESSFUL RUN
 [REPLACE THIS WITH YOUR INFORMATION] 

Repro steps

trigger: none
jobs:
##
# Configuration
##
- job: Build_HSH
  pool:
    vmImage: 'windows-latest'
  steps:

    - checkout: self  # self represents the repo where the initial Pipelines YAML file was found
      clean: true  # whether to fetch clean each time
      submodules: true

    - task: UseDotNet@2
      inputs:
        packageType: 'sdk'
        version: 6.x
        performMultiLevelLookup: true

    - task: UseDotNet@2
      inputs:
        packageType: 'runtime'
        version: 6.x
        performMultiLevelLookup: true

    - powershell: |
        dotnet --info
      displayName: 'dotnet info'

    - powershell: dotnet tool restore
      displayName: 'dotnet tool restore'

    - powershell: |
        dotnet --info
      displayName: 'dotnet info'

    - task: DotNetCoreCLI@2
      displayName: 'Test HSH'
      inputs:
        command: 'test'
        arguments: "-v:n --logger:trx /bl"

    - task: PublishBuildArtifacts@1
      displayName: 'Publish Artifact: build-log'
      condition: always()
      inputs:
        PathtoPublish: '$(Build.Repository.LocalPath)/msbuild.binlog'
        ArtifactName: 'build-log'
tweickmans commented 11 months ago

I have exactly the same thing, my unit tests were working fine with this version of the image (windows-2022).

Agent name: 'Hosted Agent'
Agent machine name: 'WIN-KLF4QQQF2O2'
Current agent version: '3.218.0'
Operating System
Microsoft Windows Server 2022
10.0.20348
Datacenter
Runner Image
Image: windows-2022
Version: 20230326.1

However, since this version:

Agent name: 'Hosted Agent'
Agent machine name: 'fv-az407-160'
Current agent version: '3.230.0'
Operating System
Microsoft Windows Server 2022
10.0.20348
Datacenter
Runner Image
Image: windows-2022
Version: 20231126.1.0

That type of error is occurring:

##[error]Testhost process for source(s) 'D:\a\1\s\LightingSequence.ImagesCombineLib.UnitTests\bin\x86\Release\net6.0-windows\ImagesCombineLib.UnitTest.dll' exited with error: You must install or update .NET to run this application.
##[error]App: D:\a\1\s\LightingSequence.ImagesCombineLib.UnitTests\bin\x86\Release\net6.0-windows\testhost.x86.exe
##[error]Architecture: x86
##[error]Framework: 'Microsoft.WindowsDesktop.App', version '6.0.0' (x86)
##[error].NET location: C:\Program Files (x86)\dotnet
##[error]The following frameworks were found:
##[error]  8.0.0 at [C:\Program Files (x86)\dotnet\shared\Microsoft.WindowsDesktop.App]
##[error]Learn more:
##[error]https://aka.ms/dotnet/app-launch-failed
##[error]To install missing framework, download:
##[error]https://aka.ms/dotnet-core-applaunch?framework=Microsoft.WindowsDesktop.App&framework_version=6.0.0&arch=x86&rid=win-x86&os=win10
##[error]. Please check the diagnostic logs for more information.
##[error]Testhost process for source(s) 'D:\a\1\s\LightingSequence.ImagesCombineLib.UnitTests\bin\x86\Release\net6.0-windows\ImagesCombineLib.UnitTest.dll' exited with error: . Please check the diagnostic logs for more information.
##[error]System.InvalidOperationException: The provided manager was not found in any slot.
v-mohithgc commented 11 months ago

Hi all, I noticed there hasn't been any recent changes done from the task side to be causing this issue all of a sudden. Going by the logs, this might be from windows-images

mikhailkoliada commented 11 months ago

@v-mohithgc hey, we do not install any x86 components of dotnet to the image, so what is usually used for x86 Brough by the ado/gh tasks

fredrikloch commented 11 months ago

@v-mohithgc we do se the same issue both on self hosted and vmss agents, the only workaround so far is to manually install .NET Desktop Runtime or more specifically the visual studio component for .Net Desktop development. Which solves the issue, leading me to believe that there might be some change in how either the UseDotnet task or the DotNetCoreCLI looks for or registers runtimes in the path

v-mohithgc commented 11 months ago

can anyone send the debug logs (system.debug=true) of the failure run to v-mohithgc @microsoft.com

jonekdahl commented 11 months ago

can anyone send the debug logs (system.debug=true) of the failure run

@v-mohithgc Aren't those already included by the OP under the section "Full task logs with system.debug enabled"?

v-mohithgc commented 11 months ago

can anyone send the debug logs (system.debug=true) of the failure run

@v-mohithgc Aren't those already included by the OP under the section "Full task logs with system.debug enabled"?

Hi, those attached logs isn't helping us here, as it has incomplete logs of a task, we might require the full debug logs of both success and failure run, if possible, please follow this doc to download the full logs and send to v-mohithgc@microsoft.com.

Thanks

fredrikloch commented 11 months ago

@v-mohithgc I will email the failing logs to you, sadly we can't produce a log for the completed build. There was a limit on how many rows I was allowed to upload in the original issue

tweickmans commented 11 months ago

Hi @v-mohithgc , I have just sent you our logs as well. Thank you.

fstarnaud commented 10 months ago

@v-mohithgc the only workaround so far is to manually install .NET Desktop Runtime or more specifically the visual studio component for .Net Desktop development.

I am hitting this issue as well and trying to implement this workaround. How can I "manually install the visual studio component for .Net Desktop development" in a YAML pipeline working with a Microsoft-hosted environment?

fstarnaud commented 10 months ago

I ended up switching over to a self-hosted environment and installing Visual Studio.

jonekdahl commented 6 months ago

Hi @v-mohithgc, would you mind sharing how this problem was resolved?