Невозможно восстановить пакеты NuGet с использованием Paket в Azure Pipelines (подача артефактов) - PullRequest
0 голосов
/ 14 апреля 2020

Я пытаюсь определить конвейер, который собирается для . NET Core решения. Зависимости управляются Paket . Зависимость загружается из Azure Artifacts feed.

На первых этапах я думал, что проблема была в Paket, и я смог определить конвейер, который строит без него (используя источник приватных пакетов , наш личный канал).

После исправления проблем с Paket у меня возникли проблемы при попытке заставить dotnet restore работать.

Это мое действительное определение YML:

trigger:
- none

pool:
  vmImage: 'windows-latest'

steps:
  - task: UseDotNet@2
    inputs:
      packageType: 'sdk'
      version: '3.1.x'

  - powershell: |
      cd ..
      dotnet tool install -g paket

  - task: setCredentialManager@0

  - task: PaketRestore@0
    inputs:
      PaketPath: '.paket'

  - task: paketCredentialCleanup@0

  # I'm not sure the following task is necessary
  - task: PowerShell@2
    inputs:
      filePath: './installcredprovider.ps1'

  - task: NuGetCommand@2
    inputs:
      command: 'restore'
      restoreSolution: '**/*.sln'
      feedsToUse: 'config'
      nugetConfigPath: './NuGet.config'

  - task: CmdLine@2
    inputs:
      script: 'dotnet restore'

  - task: DotNetCoreCLI@2
    inputs:
      command: 'build'
      projects: '*.csproj'

Задача восстановления NuGetCommand@2 завершается неудачно с этим журналом:

NuGet Version: 5.4.0.6315
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
MSBuild auto-detection: using msbuild version '16.5.0.12403' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
MSBuild P2P timeout [ms]: 120000
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\bin\msbuild.exe "C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\rjysskyy.m01.nugetinputs.targets" /t:GenerateRestoreGraphFile /nologo /nr:false /v:q /p:NuGetRestoreTargets="C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\1cpdh2ma.wgd.nugetrestore.targets" /p:RestoreUseCustomAfterTargets="True" /p:RestoreTaskAssemblyFile="C:\hostedtoolcache\windows\NuGet\5.4.0\x64\nuget.exe" /p:RestoreSolutionDirectory="d:\a\1\s\\" /p:RestoreConfigFile="d:\a\1\s\NuGet.config" /p:SolutionDir="d:\a\1\s\\" /p:SolutionName="ArtifactsVs"
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
NuGet.CommandLine.ExitCodeException: Exception of type 'NuGet.CommandLine.ExitCodeException' was thrown.
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
   at NuGet.CommandLine.MsBuildUtility.<GetProjectReferencesAsync>d__6.MoveNext()
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
--- End of stack trace from previous location where exception was thrown ---
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
d:\a\1\s\.paket\Paket.Restore.targets(219,5): error MSB3073: The command ""paket" restore --project "d:\a\1\s\ArtifactsVs.csproj" --output-path "obj" --target-framework "netcoreapp3.1"" exited with code 1. [d:\a\1\s\ArtifactsVs.csproj]
   at NuGet.CommandLine.RestoreCommand.<GetDependencyGraphSpecAsync>d__68.MoveNext()

--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.CommandLine.RestoreCommand.<DetermineInputsFromMSBuildAsync>d__63.MoveNext()
##[error]The nuget command failed with exit code(1) and error(EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
d:\a\1\s\.paket\Paket.Restore.targets(219,5): error MSB3073: The command ""paket" restore --project "d:\a\1\s\ArtifactsVs.csproj" --output-path "obj" --target-framework "netcoreapp3.1"" exited with code 1. [d:\a\1\s\ArtifactsVs.csproj])
##[error]Packages failed to restore
Finishing: NuGetCommand

В любом случае, если его пропустить, dotnet restore тоже не удается.

Источник сценария installcredprovider.ps1 is здесь .

Репозиторий можно загрузить с здесь (URL фида частично запутан).

Заранее спасибо всем, кто хочет помочь!

1 Ответ

1 голос
/ 17 апреля 2020

Я создал тестовый проект для устранения неполадок. И я обнаружил, что .NET Core sdk 2.0.0 нужен для Пакета.

Если do tnet core 2.0.0 не установлен, задача восстановления Nuget не будет выполнена с указанной выше ошибкой "It was not possible to find any compatible framework version". И задача восстановления пакета не будет выполнена с ошибкой The framework 'Microsoft.NETCore.App', version '2.0.0' was not found.

После того, как я установил .NET Core sdk 2.0.0 с UseDo tNet задача. И восстановление Nuget, и восстановление пакета успешно выполнены. Пожалуйста, проверьте ниже yaml:

pool:
  vmImage: 'windows-latest'

steps:

  - task: UseDotNet@2
    inputs:
      packageType: 'sdk'
      version: '2.0.0'

  - task: UseDotNet@2
    inputs:
      packageType: 'sdk'
      version: '3.1.x'

  - powershell: |
      cd ..
      dotnet tool install -g paket

  - task: setCredentialManager@0

  - task: PaketRestore@0
    inputs:
      PaketPath: '.paket'

  - task: paketCredentialCleanup@0

  # - task: PowerShell@2
  #   inputs:
  #     filePath: './installcredprovider.ps1'

  # - task: NuGetToolInstaller@1
  #   inputs:
  #     versionSpec: 5.x

  - task: NuGetCommand@2
    inputs:
      command: 'restore'
      restoreSolution: '**/*.sln'
      feedsToUse: 'config'
      nugetConfigPath: './NuGet.config'

Для вышеприведенного конвейера, задача setCredentialManager@0 также обязательна, но задача powershell для запуска ./installcredprovider.ps1 не нужна.

И я также нашел выше конвейер не будет работать на агенте vs2017-win2016, для более старой версии msbuild в vs2017 вызывается при выполнении команды восстановления nuget.

Пакетное восстановление, выполнение tnet восстановление и восстановление nuget, все они делают одно и то же (выполнение tnet восстановление и восстановление nuget вызовет восстановление пакета). Вы можете оставить только один из них в своем конвейере. Я проверил, и мой проект был успешно построен с любым из них.

Надеюсь, что выше помогает!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...