восстановление dotnet: при получении пакета произошла ошибка ... метаданные Корневой элемент отсутствует - PullRequest
0 голосов
/ 04 ноября 2019

У меня проблема с сборкой nuget / docker, которую я потратил пару дней на отладку, и у меня заканчиваются идеи: знаете ли вы, почему я получаю приведенную ниже ошибку?

Проблема связана с однойБазовое решение asp.net (другие, которые очень похожи, не затронуты): хотя я могу построить уязвимое решение в Visual Studio 2019 с помощью файла компоновки docker, оно не будет работать с использованием файла docker, и поэтому команда сборки docker не может быть выполнена.

Если я запускаю dockerfile, выполняя сборку, как показано ниже в командной строке:

docker build -f MStoreBosGateway/MStoreBosGatewayApi/Dockerfile --pull --no-cache -t mstorebosgateway:0.041 .

, тогда я получаю следующую ошибку:

Step 11/26 : RUN dotnet restore "MStoreBOSGateway/MStoreBOSGatewayApi/MStoreBOSGatewayApi.csproj"
>  ---> Running in 30819cb5db4f
> /usr/share/dotnet/sdk/2.2.402/NuGet.targets(123,5): error : An error
> occurred while retrieving package metadata for
> 'System.Text.Encodings.Web.4.5.0' from source
> '/usr/share/dotnet/sdk/NuGetFallbackFolder'.
> [/src/MStoreBOSGateway/MStoreBOSGatewayApi/MStoreBOSGatewayApi.csproj]
> /usr/share/dotnet/sdk/2.2.402/NuGet.targets(123,5): error :   Root
> element is missing.
> [/src/MStoreBOSGateway/MStoreBOSGatewayApi/MStoreBOSGatewayApi.csproj]
> The command '/bin/sh -c dotnet restore
> "MStoreBOSGateway/MStoreBOSGatewayApi/MStoreBOSGatewayApi.csproj"'
> returned a non-zero code: 1

У меня естьПоместите команды RUN echo после каждой строки в файле Docker, чтобы это выглядело так, как будто восстановление dotnet вызывает эту проблему. Если я сам запускаю команду восстановления dotnet, она работает нормально.

Чтобы попытаться решить эту проблему, я сделал несколько вещей, например

  • - Удалил папки obj и bin изЭто решение и проекты,
  • -Установлено и переустановлено nuget,
  • -Удалено кэши nuget для принудительной повторной загрузки пакетов,
  • -Установлено и переустановлено ядро ​​dotnet sdks,
  • - Удалил пакет, упомянутый в сообщении об ошибке ('System.Text.Encodings.Web.4.5.0), из файла проекта (это не вызвало никаких ошибок, поэтому в любом случае должно быть избыточным). Это не повлияло на эту ошибку и восстанавливает этот пакет, поэтому должно быть что-то еще, говорящее об использовании этого пакета, или, возможно, системные пакеты все равно включены по умолчанию.

Мой коллега может построить этот проект и имеетприслал мне копию, которую он может построить;Я получаю ту же проблему при создании его копии, поэтому предположим, что это что-то внешнее для проекта.

Я добавил под выводом, если я добавлю «-verbosity detail» к команде dotnet restore в файле docker.

           GET https://api.nuget.org/v3-flatcontainer/microsoft.extensions.dependencyinjection.abstractions/index.json
           OK https://api.nuget.org/v3-flatcontainer/aspnet.security.oauth.validation/index.json 342ms
           GET https://api.nuget.org/v3-flatcontainer/aspnet.security.oauth.validation/2.0.0/aspnet.security.oauth.validation.2.0.0.nupkg
           OK https://api.nuget.org/v3-flatcontainer/aspnet.security.oauth.validation/2.0.0/aspnet.security.oauth.validation.2.0.0.nupkg 52ms
           GET https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.authentication/index.json
           GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/10.0.2/newtonsoft.json.10.0.2.nupkg
     1>/usr/share/dotnet/sdk/2.2.402/NuGet.targets(123,5): error : An error occurred while retrieving package metadata for 'System.Text.Encodings.Web.4.5.0' from source '/usr/share/dotnet/sdk/NuGetFallbackFolder'. [/src/MStoreBOSGateway/MStoreBOSGatewayApi/MStoreBOSGatewayApi.csproj]
/usr/share/dotnet/sdk/2.2.402/NuGet.targets(123,5): error :   Root element is missing. [/src/MStoreBOSGateway/MStoreBOSGatewayApi/MStoreBOSGatewayApi.csproj]
           OK https://api.nuget.org/v3-flatcontainer/swashbuckle.aspnetcore.swaggergen/index.json 156ms
           GET https://api.nuget.org/v3-flatcontainer/swashbuckle.aspnetcore.swaggergen/4.0.1/swashbuckle.aspnetcore.swaggergen.4.0.1.nupkg
           OK https://api.nuget.org/v3-flatcontainer/swashbuckle.aspnetcore.swaggerui/index.json 160ms
           GET https://api.nuget.org/v3-flatcontainer/swashbuckle.aspnetcore.swaggerui/4.0.1/swashbuckle.aspnetcore.swaggerui.4.0.1.nupkg
           OK https://api.nuget.org/v3-flatcontainer/automapper/index.json 155ms
           GET https://api.nuget.org/v3-flatcontainer/automapper/8.0.0/automapper.8.0.0.nupkg
           OK https://api.nuget.org/v3-flatcontainer/swashbuckle.aspnetcore.swaggergen/4.0.1/swashbuckle.aspnetcore.swaggergen.4.0.1.nupkg 44ms
           OK https://api.nuget.org/v3-flatcontainer/swashbuckle.aspnetcore.swaggerui/4.0.1/swashbuckle.aspnetcore.swaggerui.4.0.1.nupkg 49ms
           GET https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.mvc.apiexplorer/index.json
           GET https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.mvc.core/index.json
           GET https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.mvc.dataannotations/index.json
         NuGet.Protocol.Core.Types.FatalProtocolException: An error occurred while retrieving package metadata for 'System.Text.Encodings.Web.4.5.0' from source '/usr/share/dotnet/sdk/NuGetFallbackFolder'. ---> NuGet.Packaging.Core.PackagingException: An error occurred while retrieving package metadata for 'System.Text.Encodings.Web.4.5.0' from source '/usr/share/dotnet/sdk/NuGetFallbackFolder'. ---> System.Xml.XmlException: Root element is missing.
            at System.Xml.XmlTextReaderImpl.Throw(Exception e)
            at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
            at System.Xml.XmlTextReaderImpl.Read()
            at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
            at NuGet.Packaging.Core.NuspecCoreReaderBase.LoadXml(Stream stream, Boolean leaveStreamOpen)
            at NuGet.Packaging.Core.NuspecCoreReaderBase..ctor(Stream stream, Boolean leaveStreamOpen)
            at NuGet.Packaging.NuspecReader..ctor(Stream stream)
            at NuGet.Protocol.LocalPackageFileCache.GetNuspec(String manifestPath, String expandedPath)
            at NuGet.Protocol.LocalPackageFileCache.<>c__DisplayClass6_1.<GetOrAddNuspec>b__1()
            at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
            at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
            at System.Lazy`1.CreateValue()
            at NuGet.Protocol.LocalV3FindPackageByIdResource.ProcessNuspecReader[T](String id, NuGetVersion version, Func`2 process)
            --- End of inner exception stack trace ---
            --- End of inner exception stack trace ---
            at NuGet.Protocol.LocalV3FindPackageByIdResource.ProcessNuspecReader[T](String id, NuGetVersion version, Func`2 process)
            at NuGet.Protocol.LocalV3FindPackageByIdResource.GetDependencyInfoAsync(String id, NuGetVersion version, SourceCacheContext cacheContext, ILogger logger, CancellationToken cancellationToken)
            at NuGet.Commands.SourceRepositoryDependencyProvider.GetDependenciesCoreAsync(LibraryIdentity match, NuGetFramework targetFramework, SourceCacheContext cacheContext, ILogger logger, CancellationToken cancellationToken)
            at NuGet.Commands.SourceRepositoryDependencyProvider.<>c__DisplayClass21_0.<<GetDependenciesAsync>b__0>d.MoveNext()
         --- End of stack trace from previous location where exception was thrown ---
            at NuGet.Commands.SourceRepositoryDependencyProvider.GetDependenciesAsync(LibraryIdentity libraryIdentity, NuGetFramework targetFramework, SourceCacheContext cacheContext, ILogger logger, CancellationToken cancellationToken)
            at NuGet.DependencyResolver.ResolverUtility.CreateGraphItemAsync(RemoteMatch match, NuGetFramework framework, SourceCacheContext cacheContext, ILogger logger, CancellationToken cancellationToken)
            at NuGet.DependencyResolver.ResolverUtility.FindLibraryEntryAsync(LibraryRange libraryRange, NuGetFramework framework, String runtimeIdentifier, RemoteWalkContext context, CancellationToken cancellationToken)
            at NuGet.DependencyResolver.RemoteDependencyWalker.CreateGraphNode(LibraryRange libraryRange, NuGetFramework framework, String runtimeName, RuntimeGraph runtimeGraph, Func`2 predicate, GraphEdge`1 outerEdge)
            at NuGet.DependencyResolver.RemoteDependencyWalker.CreateGraphNode(LibraryRange libraryRange, NuGetFramework framework, String runtimeName, RuntimeGraph runtimeGraph, Func`2 predicate, GraphEdge`1 outerEdge)
            at NuGet.DependencyResolver.RemoteDependencyWalker.CreateGraphNode(LibraryRange libraryRange, NuGetFramework framework, String runtimeName, RuntimeGraph runtimeGraph, Func`2 predicate, GraphEdge`1 outerEdge)
            at NuGet.DependencyResolver.RemoteDependencyWalker.CreateGraphNode(LibraryRange libraryRange, NuGetFramework framework, String runtimeName, RuntimeGraph runtimeGraph, Func`2 predicate, GraphEdge`1 outerEdge)
            at NuGet.DependencyResolver.RemoteDependencyWalker.CreateGraphNode(LibraryRange libraryRange, NuGetFramework framework, String runtimeName, RuntimeGraph runtimeGraph, Func`2 predicate, GraphEdge`1 outerEdge)
            at NuGet.DependencyResolver.RemoteDependencyWalker.CreateGraphNode(LibraryRange libraryRange, NuGetFramework framework, String runtimeName, RuntimeGraph runtimeGraph, Func`2 predicate, GraphEdge`1 outerEdge)
            at NuGet.DependencyResolver.RemoteDependencyWalker.CreateGraphNode(LibraryRange libraryRange, NuGetFramework framework, String runtimeName, RuntimeGraph runtimeGraph, Func`2 predicate, GraphEdge`1 outerEdge)
            at NuGet.Commands.ProjectRestoreCommand.WalkDependenciesAsync(LibraryRange projectRange, NuGetFramework framework, String runtimeIdentifier, RuntimeGraph runtimeGraph, RemoteDependencyWalker walker, RemoteWalkContext context, CancellationToken token)
            at NuGet.Commands.ProjectRestoreCommand.TryRestoreAsync(LibraryRange projectRange, IEnumerable`1 frameworkRuntimePairs, NuGetv3LocalRepository userPackageFolder, IReadOnlyList`1 fallbackPackageFolders, RemoteDependencyWalker remoteWalker, RemoteWalkContext context, Boolean forceRuntimeGraphCreation, CancellationToken token, TelemetryActivity telemetryActivity)
            at NuGet.Commands.RestoreCommand.ExecuteRestoreAsync(NuGetv3LocalRepository userPackageFolder, IReadOnlyList`1 fallbackPackageFolders, RemoteWalkContext context, CancellationToken token, TelemetryActivity telemetryActivity)
            at NuGet.Commands.RestoreCommand.ExecuteAsync(CancellationToken token)
            at NuGet.Commands.RestoreRunner.ExecuteAsync(RestoreSummaryRequest summaryRequest, CancellationToken token)
            at NuGet.Commands.RestoreRunner.ExecuteAndCommitAsync(RestoreSummaryRequest summaryRequest, CancellationToken token)
            at NuGet.Commands.RestoreRunner.CompleteTaskAsync(List`1 restoreTasks)
            at NuGet.Commands.RestoreRunner.RunAsync(IEnumerable`1 restoreRequests, RestoreArgs restoreContext, CancellationToken token)
            at NuGet.Commands.RestoreRunner.RunAsync(RestoreArgs restoreContext, CancellationToken token)
            at NuGet.Build.Tasks.RestoreTask.ExecuteAsync(ILogger log)
       Done executing task "RestoreTask" -- FAILED.
     1>Done building target "Restore" in project "MStoreBOSGatewayApi.csproj" -- FAILED.
     1>Done Building Project "/src/MStoreBOSGateway/MStoreBOSGatewayApi/MStoreBOSGatewayApi.csproj" (Restore target(s)) -- FAILED.

Build FAILED.

       "/src/MStoreBOSGateway/MStoreBOSGatewayApi/MStoreBOSGatewayApi.csproj" (Restore target) (1) ->
       (Restore target) ->
         /usr/share/dotnet/sdk/2.2.402/NuGet.targets(123,5): error : An error occurred while retrieving package metadata for 'System.Text.Encodings.Web.4.5.0' from source '/usr/share/dotnet/sdk/NuGetFallbackFolder'. [/src/MStoreBOSGateway/MStoreBOSGatewayApi/MStoreBOSGatewayApi.csproj]
       /usr/share/dotnet/sdk/2.2.402/NuGet.targets(123,5): error :   Root element is missing. [/src/MStoreBOSGateway/MStoreBOSGatewayApi/MStoreBOSGatewayApi.csproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:04.70
The command '/bin/sh -c dotnet restore "MStoreBOSGateway/MStoreBOSGatewayApi/MStoreBOSGatewayApi.csproj" --verbosity detailed' returned a non-zero code: 1

C:\Applications\VB2017Apps\MStoreBOSGateway>
...