2

My DevOps builds recently started failing on the step in which we use the Sitecore CLI and SCS to build an item package. To my knowledge, nothing has changed on our end, so it is unclear why the build consistently fails. We are using Sitecore CLI v 4.2.1, which apparently depends on .NET Core v 3.1.0.

Below is the relevant portion of my build pipeline:

pool:
  vmImage: 'windows-latest'
  demands:
  - msbuild
  - visualstudio
steps:
  - task: PowerShell@2
    displayName: Build Sitecore Items Package
    inputs:
      targetType: 'inline'
      script: |
        dotnet new tool-manifest
        dotnet tool install Sitecore.CLI --ignore-failed-sources --version 4.2.1
        dotnet sitecore plugin add -n Sitecore.DevEx.Extensibility.Serialization --version 4.2.1
        dotnet sitecore ser pkg create -o "acme_content.itempackage"

Here is the build log and error:

2023-07-28T15:33:59.0709582Z ##[section]Starting: Build Sitecore Items Package
2023-07-28T15:33:59.0820727Z ==============================================================================
2023-07-28T15:33:59.0820850Z Task         : PowerShell
2023-07-28T15:33:59.0820909Z Description  : Run a PowerShell script on Linux, macOS, or Windows
2023-07-28T15:33:59.0820983Z Version      : 2.220.0
2023-07-28T15:33:59.0821035Z Author       : Microsoft Corporation
2023-07-28T15:33:59.0821117Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
2023-07-28T15:33:59.0821201Z ==============================================================================
2023-07-28T15:33:59.9871431Z Generating script.
2023-07-28T15:34:00.0366626Z ========================== Starting Command Output ===========================
2023-07-28T15:34:00.0599141Z ##[command]"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\35ce6ca2-f837-4d3d-844a-373eaf773575.ps1'"
2023-07-28T15:34:19.1818561Z Creating this template will make changes to existing files:
2023-07-28T15:34:19.1831407Z   Overwrite   ./.config/dotnet-tools.json
2023-07-28T15:34:19.1831579Z 
2023-07-28T15:34:19.1831953Z Rerun the command and pass --force to accept and create.
2023-07-28T15:34:19.1857491Z 
2023-07-28T15:34:32.9432568Z You can invoke the tool from this directory using the following commands: 'dotnet tool run sitecore' or 'dotnet sitecore'.
2023-07-28T15:34:32.9433241Z Tool 'sitecore.cli' (version '4.2.1') was successfully installed. Entry is added to the manifest file D:\a\1\s\.config\dotnet-tools.json.
2023-07-28T15:34:33.3864634Z You must install or update .NET to run this application.
2023-07-28T15:34:33.3864948Z 
2023-07-28T15:34:33.3865560Z App: C:\Users\VssAdministrator\.nuget\packages\sitecore.cli\4.2.1\tools\netcoreapp3.1\any\sitecore.cli.dll
2023-07-28T15:34:33.3865913Z Architecture: x64
2023-07-28T15:34:33.3868213Z Framework: 'Microsoft.NETCore.App', version '3.1.0' (x64)
2023-07-28T15:34:33.3868780Z .NET location: C:\Program Files\dotnet\
2023-07-28T15:34:33.3868981Z 
2023-07-28T15:34:33.3869340Z The following frameworks were found:
2023-07-28T15:34:33.3870358Z   6.0.5 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2023-07-28T15:34:33.3871934Z   6.0.20 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2023-07-28T15:34:33.3872142Z 
2023-07-28T15:34:33.3872596Z Learn about framework resolution:
2023-07-28T15:34:33.3873373Z https://aka.ms/dotnet/app-launch-failed
2023-07-28T15:34:33.3873603Z 
2023-07-28T15:34:33.3874024Z To install missing framework, download:
2023-07-28T15:34:33.3876559Z https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.0&arch=x64&rid=win10-x64
2023-07-28T15:34:33.5787559Z You must install or update .NET to run this application.
2023-07-28T15:34:33.5788698Z 
2023-07-28T15:34:33.5796898Z App: C:\Users\VssAdministrator\.nuget\packages\sitecore.cli\4.2.1\tools\netcoreapp3.1\any\sitecore.cli.dll
2023-07-28T15:34:33.5800203Z Architecture: x64
2023-07-28T15:34:33.5809111Z Framework: 'Microsoft.NETCore.App', version '3.1.0' (x64)
2023-07-28T15:34:33.5813020Z .NET location: C:\Program Files\dotnet\
2023-07-28T15:34:33.5815235Z 
2023-07-28T15:34:33.5816388Z The following frameworks were found:
2023-07-28T15:34:33.5825653Z   6.0.5 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2023-07-28T15:34:33.5837279Z   6.0.20 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2023-07-28T15:34:33.5837783Z 
2023-07-28T15:34:33.5840580Z Learn about framework resolution:
2023-07-28T15:34:33.5842273Z https://aka.ms/dotnet/app-launch-failed
2023-07-28T15:34:33.5843214Z 
2023-07-28T15:34:33.5850337Z To install missing framework, download:
2023-07-28T15:34:33.5877002Z https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.0&arch=x64&rid=win10-x64
2023-07-28T15:34:33.8507014Z ##[error]PowerShell exited with code '1'.
2023-07-28T15:34:33.8864408Z ##[section]Finishing: Build Sitecore Items Package

My guess is that because we are using the windows-latest build agent, something changed and .NET Core 3.1 is no longer included by default. I also tried changing the build agent to windows-2022 and even windows-2019 (the oldest option) and it only went as far back as .NET Core version 6.x.

2 Answers 2

1

Sitecore CLI 4.2.1 does in fact depend on .NET Core 3.1.

.NET Core 3.1 reached end of life at the end of 2022:

https://devblogs.microsoft.com/dotnet/net-core-3-1-will-reach-end-of-support-on-december-13-2022/

It does appear as though the windows-latest build agent no longer ships with 3.1. You may be able to install 3.1 on the build agent as part of your build pipeline, but it would probably be a better idea to update the Sitecore CLI version. See the CLI download page here:

https://dev.sitecore.net/Downloads/Sitecore_CLI.aspx

You will also need to update your version of Sitecore Management Services on your CM instance(s).

Here are the necessary modifications to fix your build pipeline:

script: |
  dotnet new tool-manifest
  dotnet tool install Sitecore.CLI --ignore-failed-sources --version 5.2.113
  dotnet sitecore plugin add -n Sitecore.DevEx.Extensibility.Serialization --version 5.2.113
  dotnet sitecore ser pkg create -o "acme_content.itempackage"

Make sure to update any README files / documentation. This should be updated on your local development environment(s) as well. Running the above commands locally will result in some changes to the files dotnet-tools.json and sitecore.json.

1

I agree with Marcel that upgrading CLI is the recommended way in most cases.

But if for some reason you cannot upgrade, you can still install .Net Core 3.1 on build agent with the following task:

- task: UseDotNet@2
  displayName: Install .NET Core 3.x SDK
  inputs:
    version: '3.x'

That will allow you to use 4.2.1 version of CLI. Note that the x in 3.x will automatically resolve the latest version.

If you want to do this as part of an Azure DevOps pipeline step, there is a built-in step called "Use .NET Core".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.