Azure部署中心部署时会产生错误
我在尝试使用Azure应用服务部署中心将.NET API项目部署到Azure时面临错误。
这是错误:
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.
解决这个问题我该怎么办?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我通过在根项目文件夹上添加此global.json文件来解决此问题,
根据您的dotnet SDK版本,它可能会有所不同。但是只是不要使用6版。
I fix this by adding this global.json file on the root project folder
It might be different depending on your dotnet sdk version. But just don't use version 6.
似乎某些计划的迁移发生在2022年5月14日至15日左右的某些Azure App Service机器发生,导致文件夹
d:\ program Files(x86)\ dotnet \ dotnet \ sdk-manifests
消失并导致任何东西dotnet Publish
或任何msbuild
呼叫失败,如果需要解决项目中的.NET SDK参考:直到Azure Team正确固定了此功能,以下可解决方法可以使用:
上传
sdk-manifests
文件夹,其中所有内容,来自任何具有与您的发布相同的.NET SDK的机器。脚本(可以通过global.json设置)到Azure App Service上的FTP部署根文件夹,该文件夹是d:\ home
,也通过>%home%环境变量。
在您的“ dotnet发布”或“ msbuild”调用之前,请立即添加以下命令:
set dotnetsdk_workload_manifest_roots =%home%\ sdk-manifests
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 anydotnet publish
or anymsbuild
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:
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 isD:\home
there, also referred to via the%HOME%
environment variable.Add the following command immediately before your "dotnet publish" or "msbuild" call:
set DOTNETSDK_WORKLOAD_MANIFEST_ROOTS=%HOME%\sdk-manifests
SDK版本6.0.201似乎是具有问题的版本。
使用Global-JSON文件固定SDK版本后,我可以部署。
如何固定SDK版本: https://learn.microsoft。 com/en-us/dotnet/core/tools/global-json
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
解决方法之一是使用Azure管道。
参考: deploy asp.net core core core core to Azure App Service to Azure App Service
One of the workarounds is to use Azure pipelines.
REFERENCES: Deploy ASP.NET Core websites to Azure App Service with Azure Pipelines