I recently upgraded from Umbraco 10.x (.NET 6 Core) to 13.x (.NET 8 Core).
Since then the pipeline to build the project has not been failing or complaining but I suspect it is still building in .NET 6 somehow as it doesn't run. I can also compare the following files after a local publish vs. the pipeline's output.
myproj.deps.json has { "runtimeTarget": { "name": ".NETCoreApp,Version=v6.0" ...
myproj.runtimeconfig.json has { "runtimeOptions" : { "tfm": "net6.0" ...
Local build/publish those have 8.0.
Trying solutions from similar posts I've added a task step of "Use .NET Core"
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk 8.x'
inputs:
version: 8.x
I even added a dotnet info to prove that 8 was there:
steps:
- task: DotNetCoreCLI@2
displayName: 'dotnet info'
inputs:
command: custom
custom: '--info'
But when it gets to the build step I get the following error:
steps:
- task: DotNetCoreCLI@2
displayName: Build
inputs:
projects: '**/myproj.csproj'
arguments: '--configuration $(BuildConfiguration) --no-restore --framework net8.0'
##[error]C:\hostedtoolcache\windows\dotnet\sdk\8.0.204\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(266,5): Error NETSDK1005: Assets file 'D:\a\8\s\Dev\Main\myproj\obj\project.assets.json' doesn't have a target for 'net8.0'. Ensure that restore has run and that you have included 'net8.0' in the TargetFrameworks for your project.
Same result with or without --framework net8.0
.
Even though I'm not doing NuGet specifically I tried adding the following with no change.
steps:
- task: NuGetToolInstaller@1
displayName: 'Use NuGet 5.8'
inputs:
versionSpec: 5.8
I have also tried changing the host from windows-latest to windows-2022. No change.
I even tried changing the following item in the project file from TargetFramework
to TargetFrameworks
.
<TargetFramework>net8.0</TargetFramework>
ANY ideas or help would be greatly appreciated.
I was able to get a successful build/deployment after creating a new build pipeline from scratch.
For whatever reason, the old pipeline was holding on to something it shouldn't have (even Clean didn't help).