.net - Azure 部署中心在部署时生成错误

标签 .net azure azure-devops azure-web-app-service

我在尝试使用 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.

我该如何解决这个问题?

最佳答案

我通过在根项目文件夹中添加此 global.json 文件来修复此问题

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

根据您的 dotnet sdk 版本,它可能会有所不同。但不要使用版本 6。

关于.net - Azure 部署中心在部署时生成错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72267221/

相关文章:

c# - 如何区分 BackgroundWorker.RunWorkerCompleted 事件处理程序中的不同异常类型

c# - 是否应该路由 MVVM 事件?

azure - LINQ2Twitter 回调在本地主机上工作,但在 Azure 上不起作用

Azure DevOps 自托管代理 - 如何复制云托管代理?

c# - XmlSerializer - 反射(reflect)类型时出错

.net - BouncyCaSTLe包使用.NET Framework版本恢复,但在Linux上运行良好

azure - Android 设备未从 Azure 通知中心收到通知消息

Azure Blob 存储 - 自动移动到存档存储层

tfs - Visual Studio Online - 工作项未在冲刺板中正确显示?

azure-devops - 如何配置 Azure DevOps 发布管道以使用来自 Azure Artifacts 的通用包?