Reputation: 4375
My 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://learn.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- master
pool:
vmImage: 'windows-latest'
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: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
I have a csproj called DatabaseModeler Tester
:
When the pipeline runs, I get these errors:
This project is not a test project, nor does it have any test dependencies.
Upvotes: 0
Views: 1620
Reputation: 115025
The default value of the VsTest task is:
{
"name": "testAssemblyVer2",
"type": "multiLine",
"label": "Test files",
"defaultValue": "**\\*test*.dll\n!**\\*TestAdapter.dll\n!**\\obj\\**",
"required": true,
"helpMarkDown": "Run tests from the specified files.<br>Ordered tests and webtests can be run by specifying the .orderedtest and .webtest files respectively. To run .webtest, Visual Studio 2017 Update 4 or higher is needed. <br><br>The file paths are relative to the search folder. Supports multiple lines of minimatch patterns. [More information](https://aka.ms/minimatchexamples)",
"groupName": "testSelection",
"properties": {
"rows": "3",
"resizable": "true"
},
"visibleRule": "testSelector = testAssemblies"
},
https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/VsTestV2/task.json#L72
Note that the task will pick up any assembly that has "test" in its name.
"defaultValue": "**\\*test*.dll\n!**\\*TestAdapter.dll\n!**\\obj\\**",
Setting the testAssemblyVer2
property on the VsTest2 task will allow you to pick the right test assemblies.
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
testAssemblyVer2: "**\\*test*.dll\n!**\\*TestAdapter.dll\n!**\\obj\\**\n!**\Tester*.dll",
In this case I added a specific exclusion for Tester*.dll
: \n!**\Tester*.dll
, but you can also create a more specific rule to select your test assumblies based on your solution's folder structure, for example when your tests all sit in the tests
folder:
"**\\tests\\*test*.dll"
Upvotes: 3