10

I`m facing an error when trying to deploy an .NET API project to Azure using Azure App Service Deployment Center.

This is the error:

Project "D:\home\site\repository\Api\Custom.Common.API\Custom.Common.API.csproj" on node 1 (Restore target(s)).
D:\home\site\repository\Api\Custom.Common.API\Custom.Common.API.csproj : error MSB4242: SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildSdkResolver" failed while attempting to resolve the SDK "Microsoft.NET.Sdk.Web". Exception: "System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\Program Files (x86)\dotnet\sdk-manifests'.
D:\home\site\repository\Api\Custom.Common.API\Custom.Common.API.csproj : error MSB4242:    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
D:\home\site\repository\Api\Custom.Common.API\Custom.Common.API.csproj : error MSB4242:    at System.IO.FileSystemEnumerableIterator`1.CommonInit()
D:\home\site\repository\Api\Custom.Common.API\Custom.Common.API.csproj : error MSB4242:    at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
D:\home\site\repository\Api\Custom.Common.API\Custom.Common.API.csproj : error MSB4242:    at System.IO.Directory.GetDirectories(String path)
D:\home\site\repository\Api\Custom.Common.API\Custom.Common.API.csproj : error MSB4242:    at Microsoft.NET.Sdk.WorkloadManifestReader.SdkDirectoryWorkloadManifestProvider.FallbackForMissingManifest(String manifestId)
D:\home\site\repository\Api\Custom.Common.API\Custom.Common.API.csproj : error MSB4242:    at Microsoft.NET.Sdk.WorkloadManifestReader.SdkDirectoryWorkloadManifestProvider.GetManifestDirectories()
D:\home\site\repository\Api\Custom.Common.API\Custom.Common.API.csproj : error MSB4242:    at Microsoft.NET.Sdk.WorkloadManifestReader.SdkDirectoryWorkloadManifestProvider.<GetManifests>d__7.MoveNext()
D:\home\site\repository\Api\Custom.Common.API\Custom.Common.API.csproj : error MSB4242:    at Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver.LoadManifestsFromProvider(IWorkloadManifestProvider manifestProvider)
D:\home\site\repository\Api\Custom.Common.API\Custom.Common.API.csproj : error MSB4242:    at Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver.Create(IWorkloadManifestProvider manifestProvider, String dotnetRootPath, String sdkVersion, String userProfileDir)
D:\home\site\repository\Api\Custom.Common.API\Custom.Common.API.csproj : error MSB4242:    at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.CachingWorkloadResolver.Resolve(String sdkReferenceName, String dotnetRootPath, String sdkVersion, String userProfileDir)
D:\home\site\repository\Api\Custom.Common.API\Custom.Common.API.csproj : error MSB4242:    at Microsoft.DotNet.MSBuildSdkResolver.DotNetMSBuildSdkResolver.Resolve(SdkReference sdkReference, SdkResolverContext context, SdkResultFactory factory)
D:\home\site\repository\Api\Custom.Common.API\Custom.Common.API.csproj : error MSB4242:    at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.ResolveSdk(Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive, Boolean isRunningInVisualStudio)""
Done Building Project "D:\home\site\repository\Api\Custom.Common.API\Custom.Common.API.csproj" (Restore target(s)) -- FAILED.

Build FAILED.

What can I do to resolve this?

1
  • 1
    Facing the same issue. Tried to update the app service Stack settings and tried to scale up and scale down the application but nothing helped. Commented May 17, 2022 at 6:45

4 Answers 4

6

I fix this by adding this global.json file on the root project folder

{
  "sdk": {
    "version": "5.0.406"
  }
}

It might be different depending on your dotnet sdk version. But just don't use version 6.

Sign up to request clarification or add additional context in comments.

2 Comments

This actually works and doesn't require the manual copying of the SDK. "3.1.118" can be used for Asp.NetCore 3.1
Loved this solution. Question: Do I specify "rollForward": "latestPatch" too ? as specified here: learn.microsoft.com/en-us/dotnet/core/tools/global-json
3

It seems that some planned migration happened to some of Azure App Service machines at around 14-15 May 2022 resulting in the folder D:\Program Files (x86)\dotnet\sdk-manifests disappearing and causing any dotnet publish or any msbuild call to fail, if it needs to resolve a .NET SDK reference in the project:

Until this is fixed properly by the Azure team, the following workaround can be used:

  1. Uploaded the sdk-manifests folder, with all the contents, from any machine which has the same version of the .NET SDK installed as the one required (used) by your publishing script (which can be set via global.json) to the FTP deployment root folder on Azure App Service, which is D:\home there, also referred to via the %HOME% environment variable.

  2. Add the following command immediately before your "dotnet publish" or "msbuild" call:

set DOTNETSDK_WORKLOAD_MANIFEST_ROOTS=%HOME%\sdk-manifests

1 Comment

Is this being tracked as a bug anywhere so we know when it is fixed?
3

It appears that SDK version 6.0.201 is the version which has the issue.

I was able to deploy after pinning the SDK version using the global-json file.

How to pin sdk version: https://learn.microsoft.com/en-us/dotnet/core/tools/global-json

{
  "sdk": {
    "version": "6.0.102"
  }
}

2 Comments

Thanks. This worked for me (though admittedly I didn't check if the "normal" deployment flow had been fixed yet). "Normal" meaning the one presented in the ASP.NET Core Web API Getting Started guide.
which .net core version are you using? .NET 6? I am on .NET 5, is it ok if i use "version": "5.0.406"
1

One of the workarounds is to use Azure pipelines.

  1. Try creating an Azure Pipeline from the DevOps portal.
  2. Publish the website in a zip.
  3. Deploy to Azure App Service by creating Service Connection in Azure DevOps.

REFERENCES: Deploy ASP.NET Core websites to Azure App Service with Azure Pipelines

1 Comment

Hey, I didn't do anything, however, when I tried to redeploy today, it worked. Maybe it was some error with Azure itself and it was resolved. Thank you for your help, anyways, it will help me to create pipelines.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.