DEV Community

Olivier Maléa
Olivier Maléa

Posted on

🏆Quick-win : Fix erreur NETSDK1045 avec .net 7 preview

Comment résoudre l'erreur : error NETSDK1045 The current .NET SDK does not support targeting .NET 7.0.

Dans un pipeline Azure DevOps, en utilisant le sdk .net6 dans une task de CI, aucun problème, tout fonctionne sans accroc, jusque là rien d'anormal.
L'extrait ci-dessous présente une task simple, issue d'un fichier yaml:

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk'
  inputs:
    packageType: sdk
    version: 6.x
    installationPath: $(Agent.ToolsDirectory)/dotnet
Enter fullscreen mode Exit fullscreen mode

Lorsque vous utilisez le sdk .net7 (Ă  l'heure actuelle en Ă©tat de preview), celui-ci causera une belle erreur :
error NETSDK1045: The current .NET SDK does not support targeting .NET 7.0.

Pour résoudre ce problème, c'est très simple: ajoutez le paramètre includePreviewVersions: true, comme détaillé ci-dessous:

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk'
  inputs:
    packageType: sdk
    version: 7.x
    includePreviewVersions: true
    installationPath: $(Agent.ToolsDirectory)/dotnet
Enter fullscreen mode Exit fullscreen mode

C'est gagné !

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs