当尝试使用将.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.
我能做些什么来解决这个问题?
发布于 2022-05-17 19:50:11
我通过在根项目文件夹中添加这个global.json文件来修复这个问题。
{
"sdk": {
"version": "5.0.406"
}
}
根据dotnet版本的不同,可能会有所不同。但不要使用第6版。
发布于 2022-05-17 20:22:52
在2022年5月14日至15日左右,一些Azure应用程序服务机器似乎发生了一些计划迁移,导致文件夹D:\Program Files (x86)\dotnet\sdk-manifests
消失,如果需要解析项目中的.NET SDK引用,则会导致任何dotnet publish
或任何msbuild
调用失败:
在Azure团队正确修复此问题之前,可以使用以下解决方法:
sdk-manifests
文件夹从安装了与发布脚本(可以通过global.json设置的)所需的.NET SDK版本相同的计算机上载到Azure上的D:\home
部署根文件夹,该文件夹也通过%HOME%
环境变量引用。set DOTNETSDK_WORKLOAD_MANIFEST_ROOTS=%HOME%\sdk-manifests
发布于 2022-05-31 09:15:47
看起来SDKVersion6.0.201是有问题的版本。
在使用全局-json文件固定SDK版本之后,我能够进行部署。
如何插入sdk版本:https://learn.microsoft.com/en-us/dotnet/core/tools/global-json
{
"sdk": {
"version": "6.0.102"
}
}
https://stackoverflow.com/questions/72267221
复制相似问题