Azure app service continuous deployment failed after upgrading project to .NET 9

Pongpak Santithamkul 10 Reputation points
2024-11-22T13:38:31.1666667+00:00

After upgrading our application to use .NET 9, Azure app service build service is unable to build and deploy our application.

We already changed stack settings and continuous deployment settings to .NET 9User's imageUser's image

A deployment log shows that MSBuild version is out-of-date

"C:\home\site\repository\project-path" (default target) (1:7) ->
(_WarnWhenUsingNET9AndVSPriorTo1712 target) -> 
  C:\Program Files (x86)\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets(135,5): warning NETSDK1223: Targeting .NET 9.0 or higher in Visual Studio 2022 17.11 is not supported. [C:\home\site\repository\project-path]

Any idea how to resolve this issue?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,673 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,022 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. JasonPan - MSFT 5,991 Reputation points Microsoft Vendor
    2024-11-26T06:24:09.8166667+00:00

    Hi @Pongpak Santithamkul,

    From the error message, .NET 9 may not be available in all regions.

    You can try to verify it by using another region. We can also try to solve this problem by adding additional extensions.

    User's image

    Best Regards

    Jason

    0 comments No comments

  2. ajkuma 27,356 Reputation points Microsoft Employee
    2024-11-29T11:37:29.71+00:00

    Pongpak Santithamkul, Just following-up, hope you add a chance to check the suggestions by Jason. Kindly try and let us know.

    Adding to the above,

    Version requirements for .NET 9 SDK

    .NET 9.0.100 won't load in Visual Studio version 17.10 or earlier. Visual Studio version 17.11 doesn't make net9.0 available in the project properties. .NET 9.0.100 warns when targeting net9.0 and using Visual Studio version 17.11:

    NETSDK1223: Targeting .NET 9.0 or higher in Visual Studio 2022 17.11 is not supported.

    As an alternative, you may define global.json file at the root of your project to force build using the correct .net version. Checkout this similar discussion thread.

    global.json

    {
      "sdk": {
        "version": "8.0.400",
        "rollForward": "latestFeature"
      }
    }
    
    

    If the answer helped (pointed, you in the right direction) > please click Accept Answer to benefit the community find answers quickly to similar question.

    0 comments No comments

  3. Pongpak Santithamkul 10 Reputation points
    2024-12-02T08:26:09.5966667+00:00

    I tried both suggestions, but App Service Build Service still failed to build .NET 9 project. I think the problem is because a generated CI script is relying on MSBuild but there is no MSBuild 17.12 installed in the app service.

    echo Handling ASP.NET Core Web Application deployment with MSBuild16.
    
    :: 1. Restore, Build and publish
    call :ExecuteCmd "%MSBUILD_16_DIR%\MSBuild.exe" /restore "%DEPLOYMENT_SOURCE%\Zortout.API.Core\Zortout.API.Core.Server\Zortout.API.Core.Server.csproj" /p:DeployOnBuild=true /p:configuration=Release /p:publishurl="%DEPLOYMENT_TEMP%" %SCM_BUILD_ARGS%
    IF !ERRORLEVEL! NEQ 0 goto error
    
    :: 2. KuduSync
    call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_TEMP%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
    IF !ERRORLEVEL! NEQ 0 goto error
    
    

    User's image

    Full log:

    Command: "C:\home\site\deployments\tools\deploy.cmd"
    Handling ASP.NET Core Web Application deployment with MSBuild16.
    MSBuild version 17.11.2+c078802d4 for .NET Framework
    Build started 12/2/2024 3:05:37 PM.
    Project "C:\home\site\repository\MySolution\MyProj\MyProj.csproj" on node 1 (Restore target(s)).
    _GetAllRestoreProjectPathItems:
      Determining projects to restore...
    Restore:
      X.509 certificate chain validation will use the default trust store selected by .NET for code signing.
      X.509 certificate chain validation will use the default trust store selected by .NET for timestamping.
      Assets file has not changed. Skipping assets file writing. Path: C:\home\site\repository\MySolution\MyProj\obj\project.assets.json
      Restored C:\home\site\repository\MySolution\MyProj\MyProj.csproj (in 518 ms).
      Assets file has not changed. Skipping assets file writing. Path: C:\home\site\repository\MySolution\MySolution.Data\obj\project.assets.json
      Restored C:\home\site\repository\MySolution\MySolution.Data\MySolution.Data.csproj (in 8 ms).
      
      NuGet Config files used:
          C:\home\site\repository\NuGet.Config
      
      Feeds used:
          https://api.nuget.org/v3/index.json
      All projects are up-to-date for restore.
    Done Building Project "C:\home\site\repository\MySolution\MyProj\MyProj.csproj" (Restore target(s)).
    Project "C:\home\site\repository\MySolution\MyProj\MyProj.csproj" on node 1 (default targets).
    C:\Program Files (x86)\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets(135,5): warning NETSDK1223: Targeting .NET 9.0 or higher in Visual Studio 2022 17.11 is not supported. [C:\home\site\repository\MySolution\MyProj\MyProj.csproj]
    C:\Program Files (x86)\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1060: Error reading assets file: Error loading lock file 'C:\home\site\repository\MySolution\MyProj\obj\project.assets.json' : Could not load file or assembly 'System.Text.Json, Version=8.0.0.4, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified. [C:\home\site\repository\MySolution\MyProj\MyProj.csproj]
    Done Building Project "C:\home\site\repository\MySolution\MyProj\MyProj.csproj" (default targets) -- FAILED.
    Build FAILED.
    "C:\home\site\repository\MySolution\MyProj\MyProj.csproj" (default target) (1:7) ->
    (_WarnWhenUsingNET9AndVSPriorTo1712 target) -> 
      C:\Program Files (x86)\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets(135,5): warning NETSDK1223: Targeting .NET 9.0 or higher in Visual Studio 2022 17.11 is not supported. [C:\home\site\repository\MySolution\MyProj\MyProj.csproj]
    "C:\home\site\repository\MySolution\MyProj\MyProj.csproj" (default target) (1:7) ->
    (ResolvePackageAssets target) -> 
      C:\Program Files (x86)\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1060: Error reading assets file: Error loading lock file 'C:\home\site\repository\MySolution\MyProj\obj\project.assets.json' : Could not load file or assembly 'System.Text.Json, Version=8.0.0.4, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified. [C:\home\site\repository\MySolution\MyProj\MyProj.csproj]
        1 Warning(s)
        1 Error(s)
    Time Elapsed 00:00:03.56
    Failed exitCode=1, command="C:\Program Files (x86)\MSBuilds\17.11.2\MSBuild\Current\Bin\MSBuild.exe" /restore "C:\home\site\repository\MySolution\MyProj\MyProj.csproj" /p:DeployOnBuild=true /p:configuration=Release /p:publishurl="C:\local\Temp\8dd12a81a7f70c3"
    An error has occurred during web site deployment.
    \r\nC:\Program Files (x86)\SiteExtensions\Kudu\103.100930.002\bin\Scripts\starter.cmd "C:\home\site\deployments\tools\deploy.cmd"
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.