steps:
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: 'build'
arguments: '--configuration $(BuildConfiguration)'
- task: DotNetCoreCLI@2
displayName: dotnet test
inputs:
command: test
projects: 'Playtech.Neon.Privacy.TestPlaytech.Neon.Privacy.Test.csproj'
arguments: '--configuration $(buildConfiguration)'
我注意到 test
步骤再次构建了解决方案,这很愚蠢,因为
解决方案已通过构建步骤构建,因此测试应仅使用已创建的 bin
目录。
能做到吗?怎么样?
答案 0 :(得分:1)
默认情况下,像 test 或 pack 这样的 Dotnet 命令会构建项目。
有两种解决方案:
-task: DotNetCoreCLI@2
displayName: dotnet test
inputs:
command: test
projects: 'Playtech.Neon.Privacy.TestPlaytech.Neon.Privacy.Test.csproj'
arguments: '--no-build --configuration $(buildConfiguration)'
- script: dotnet test Playtech.Neon.Privacy.TestPlaytech.Neon.Privacy.Test.dll
workingDirectory: '<Path_To_The_Build_Directory>'
displayName: Run Tests
您可能可以对 DotNetCoreCLI@2 任务执行相同的操作,但我没有对此进行测试。
但总体阅读documentation始终是一个好的第一步;)