Reputation: 2436
I have two unit test projects (created when I was learning how to unit test).
When I run my build (yaml) in my azure pipeline my .NET Core 2.2 project runs its test but I can't seem to get my other project to run its test.
My yaml might be a little dirty trying to solve this issue. Please let me know if you see something not right.
# 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://learn.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'
Upvotes: 0
Views: 3617
Reputation: 76760
How to get my Auzure-Pipeline to run .NET Framework 4.7 Test
That because you are publishing the solution in the Visual Studio build task instead of building it.
As the VSBuild task in your yaml:
- 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)'
The web application project will be publish to the artifacts folder $(build.artifactStagingDirectory)
, but the test project will not be built.
That the reason why you did not seem to get your other project to run .NET Framework 4.7
Test.
To resolve this issue, we need to build the solution (or the test projects) instead of publishing it, so you need add a visual studio build task to build this solution, then test it.
Hope this helps.
Upvotes: 3