我正在尝试在Azure DevOps上恢复一个.Net核心项目,如下所示:
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.发布于 2021-01-15 05:44:25
你可以用一种更简单的方法来做这件事。
#Restore packages with the .NET Core CLI task
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: 'restore'
projects: '**/*.sln'如果您想使用自己的方式,请确保在恢复之前通过列出文件来选择正确的路径
- script: ls '$(solutionPath)'https://stackoverflow.com/questions/65727200
复制相似问题