Build fails [dotnet The application '--version' does not exist]

ebenezarp's Avatar

ebenezarp

06 Dec, 2023 01:47 PM

Build fails and the error message says that the dotnet --version doesn't exist. The build was working fine till a week before, no changes was done. Please find the build log below.

dotnet --version
The command could not be loaded, possibly because:
* You intended to execute a .NET application: The application '--version' does not exist. * You intended to execute a .NET SDK command: A compatible .NET SDK was not found.

Requested SDK version: 2.2.100
global.json file: C:\projects\planter\global.json

Installed SDKs:

Install the [2.2.100] .NET SDK or update [C:\projects\planter\global.json] to match an installed SDK.

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
3.0.103 [C:\Program Files\dotnet\sdk]
3.1.202 [C:\Program Files\dotnet\sdk]
3.1.426 [C:\Program Files\dotnet\sdk]
5.0.408 [C:\Program Files\dotnet\sdk]
5.0.416 [C:\Program Files\dotnet\sdk]
8.0.100 [C:\Program Files\dotnet\sdk]
Command exited with code -2147450735

  1. Support Staff 1 Posted by Owen McDonnell on 06 Dec, 2023 06:28 PM

    Owen McDonnell's Avatar

    Are you subscribed to the technical updates newsletter?
    .Net core 2 was deprecated in the last image update as mentioned in the newsletter.

    In the near term you can revert to Previous Visual Studio 2019 or 2022 image to get your build working again, but of course this will only work until a new image update.
    You could also add the following script to the install stage of your build.

    - ps: |
        Invoke-WebRequest -Uri 'https://dot.net/v1/dotnet-install.ps1' -UseBasicParsing -OutFile "$env:temp\dotnet-install.ps1"
        & "$env:temp\dotnet-install.ps1" -Architecture x64 -Version '2.2.100' -InstallDir "$env:ProgramFiles\dotnet"
    
  2. 2 Posted by ebenezarp on 07 Dec, 2023 05:46 AM

    ebenezarp's Avatar

    Hi Owen,

    Thanks for the response. I tried changing to Previous Visual Studio 2019, 2022 image and also added this script to my install stage. Still the same issue. I have attached screenshots (of the environment settings and build outcome). I'd appreciate your help.

    Note: I am not subscribed to the newsletter. I will check and subscribe to it.

  3. Support Staff 3 Posted by Owen McDonnell on 07 Dec, 2023 04:13 PM

    Owen McDonnell's Avatar

    Does your repo have an appveyor.yml config file in it, or perhaps a custom named config file, which would be overriding those ui settings?

  4. 4 Posted by Sathish B on 08 Dec, 2023 05:01 AM

    Sathish B's Avatar

    Hi Owen,

    Ebenezer and I working in same team. Do we need to remove the appveyor.yml file to apply the given script?

  5. Support Staff 5 Posted by Owen McDonnell on 08 Dec, 2023 06:33 AM

    Owen McDonnell's Avatar

    First, I would recommend taking a look at the relevant documentation here.
    If you are currently using a configuration file, you can run that install script in an install block like this,

    install: 
      - ps: |
          Invoke-WebRequest -Uri 'https://dot.net/v1/dotnet-install.ps1' -UseBasicParsing -OutFile "$env:temp\dotnet-install.ps1"
          & "$env:temp\dotnet-install.ps1" -Architecture x64 -Version '2.2.100' -InstallDir "$env:ProgramFiles\dotnet"
    
    and you can specify the image like this,
    image: Previous Visual Studio 2019
    
    Again, the docs demonstrate this and more.
  6. 6 Posted by ebenezarp on 11 Dec, 2023 04:54 AM

    ebenezarp's Avatar

    Hi Owen,

    This issue is now resolved. Thank you for your valuable guidance in fixing this. I appreciate your help.

  7. Support Staff 7 Posted by Owen McDonnell on 15 Dec, 2023 06:16 AM

    Owen McDonnell's Avatar

    No worries, thanks for updating.

  8. Owen McDonnell closed this discussion on 15 Dec, 2023 06:16 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac