【问题标题】:How to get my Auzure-Pipeline to run .NET Framework 4.7 Test如何让我的 Azure-Pipeline 运行 .NET Framework 4.7 测试
【发布时间】:2020-02-15 13:05:13
【问题描述】:

我有两个单元测试项目(在我学习如何进行单元测试时创建)。

当我在我的天蓝色管道中运行我的构建 (yaml) 时,我的 .NET Core 2.2 项目运行它的测试,但我似乎无法让我的其他项目运行它的测试。

我的 yaml 试图解决这个问题可能有点脏。如果您发现不对劲的地方,请告诉我。

# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool: Default

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: DotNetCoreCLI@2
  inputs:
    command: test
    projects: '**/*.csproj'
    arguments: '--configuration $(buildConfiguration)'

- task: VisualStudioTestPlatformInstaller@1
  inputs:
    packageFeedSelector: 'nugetOrg'
    versionSelector: 'latestStable'


- task: VSTest@2
  inputs:
    testSelector: 'testAssemblies'
    testAssemblyVer2: |
      **\*test*.dll
      !**\*TestAdapter.dll
      !**\obj\**
    searchFolder: '$(System.DefaultWorkingDirectory)'
    vsTestVersion: 'toolsInstaller'

【问题讨论】:

    标签: unit-testing yaml azure-pipelines


    【解决方案1】:

    如何让我的 Auzure-Pipeline 运行 .NET Framework 4.7 测试

    这是因为您在 Visual Studio 构建任务中发布解决方案,而不是构建它。

    作为 yaml 中的 VSBuild 任务:

    - task: VSBuild@1
      inputs:
        solution: '$(solution)'
        msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
        platform: '$(buildPlatform)'
        configuration: '$(buildConfiguration)'
    

    Web 应用程序项目将发布到工件文件夹 $(build.artifactStagingDirectory),但不会构建测试项目。

    这就是你似乎没有让你的其他项目运行.NET Framework 4.7测试的原因。

    要解决此问题,我们需要构建解决方案(或测试项目)而不是发布它,因此您需要添加一个 Visual Studio 构建任务来构建此解决方案,然后对其进行测试。

    希望这会有所帮助。

    【讨论】:

    • 赞成。我在包含框架和核心测试项目的解决方案中遇到了类似的问题。
    猜你喜欢
    • 1970-01-01
    • 2019-12-17
    • 1970-01-01
    • 2022-07-26
    • 2018-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-15
    相关资源
    最近更新 更多