Reputation: 13796
I just updated my solution to .NET7. I have a build/release pipeline setup on Azure Devops which now fails in the "Restore" step.
This is first error, which is then followed by multiple other errors of the same type:
2:3>Target "_CheckForUnsupportedNETCoreVersion" in file "C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets" from project "D:\a\1\s\xxxx\xxxx.csproj" (target "CollectPackageReferences" depends on it): Using "NETSdkError" task from assembly "C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets..\tools\net6.0\Microsoft.NET.Build.Tasks.dll". Task "NETSdkError" 2:3>C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 7.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0. [D:\a\1\s\xxxx\xxxx.csproj] Done executing task "NETSdkError" -- FAILED.
I've tried using both "Windows Latest" and "Windows 2022" under "Agent specification" but neither works. I would have thought that "Windows Latest" would get automatically updated to the latest SDK once it's released? What do I have to change to make this build pipeline work with .NET7?
Upvotes: 5
Views: 6371
Reputation: 525
I had the same issue. But adding just netcore sdk didn't work for me, also added NuGet 6.5.0
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk 7.x'
inputs:
version: 7.x
- task: NuGetToolInstaller@0
displayName: 'Use NuGet 6.5.0'
inputs:
versionSpec: 6.5.0
- task: NuGetCommand@2
displayName: 'NuGet restore'
inputs:
restoreSolution: '$(Parameters.solution)'
- task: VSBuild@1
displayName: 'Build solution'
inputs:
solution: '$(Parameters.solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\IdentityApp.API.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
- task: VSTest@2
displayName: 'Test Assemblies'
inputs:
testAssemblyVer2: |
**\$(BuildConfiguration)\*test*.dll
!**\obj\**
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
- task: PublishSymbols@2
displayName: 'Publish symbols path'
inputs:
SearchPattern: '**\bin\**\*.pdb'
PublishSymbols: false
continueOnError: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
ArtifactName: '$(Parameters.ArtifactName)'
condition: succeededOrFailed()
Upvotes: 2
Reputation: 2779
If pipeline configuration is in YAML an additional task is needed at the beginning:
- task: UseDotNet@2
displayName: 'Install .NET Core SDK 7.x'
inputs:
version: 7.x
Upvotes: 8
Reputation: 13796
I found the solution. I had to add an additional step in the beginning which installs the .NET7 SDK.
Upvotes: 8