.net - 无法在 Azure Devops 上使用 DotNetCoreCLI 任务恢复 .Net Core 解决方案

标签 .net azure azure-devops azure-pipelines

我正在尝试在 Azure DevOps 上恢复 .Net Core 项目,如下所示:

steps:

- task: PowerShell@2
  displayName: 'Get solution path'
  inputs:
    targetType: 'inline'
    script: |
      $solutionPath = Get-ChildItem -Filter *.sln -Recurse | Select-Object -Expand Directory -First 1

      Write-Host "##vso[task.setvariable variable=solutionPath]$solutionPath"

- task: PowerShell@2
  displayName: 'Restore'
  inputs:
    targetType: 'inline'
    script: |
      dotnet restore
    workingDirectory: "$(solutionPath)"

- task: DotNetCoreCLI@2
  displayName: 'Restore'
  inputs:
    command: 'restore'
    workingDirectory: "$(solutionPath)"

我使用 PowerShell 的第一个恢复任务工作得很好,但我使用 DotNetCoreCLI 的第二个恢复任务失败并出现以下错误:

MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.

最佳答案

您可以用更简单的方式做到这一点

#Restore packages with the .NET Core CLI task
- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: 'restore'
    projects: '**/*.sln'

如果您想使用自己的方式,请确保在恢复之前通过列出文件来选择正确的路径

- script: ls '$(solutionPath)'

关于.net - 无法在 Azure Devops 上使用 DotNetCoreCLI 任务恢复 .Net Core 解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65727200/

相关文章:

database - 电源应用程序的数据存储选项

c# - 如何在使用反射加载的程序集中使用 CaSTLe.Windsor

javascript - Pusher 是否允许非 ASCII (JSON) 格式的传输负载?

.net - 如何使用SmtpClient.SendAsync发送带有附件的电子邮件?

azure - Office365 Sharepoint Social.feed AAD 授权

azure - 继续部署无法与 github 私有(private)存储库正常工作

visual-studio - (Azure DevOps 测试计划)是否可以在没有 Visual Studio 的情况下将自动化测试关联到测试用例?

使用 Azure Devops Pipeline 部署 Oracle 对象

azure-devops - 如何从 Azure DevOps CI 上的多个文件夹复制文件?

c# - sqlite-net 异步 API 是否支持处置?