Added a Run tests task to a pipeline. Tests pass, but the log shows the below error:
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Unable to find **\obj\release\netcoreapp2.2\myProject.deps.json. Make sure test project has a nuget reference of package "Microsoft.NET.Test.Sdk".
The project does have the nuget package for the Test.Sdk.
What do I miss here? Thank you.
The error said myProject.deps.json is missing from folder "\obj\release..". This folder contains the output files of dotnet build,which doesnot have file myProject.deps.json. You might need to point the vstest search folder to the published folder of dotnet publish task.
You can add an output arguments (-o $(build.artifactstagingdirectory)) for your dotnet publish task to specifically publish to a folder.
For below example the output files are published to $(build.artifactstagingdirectory) which has file myProject.deps.json.
Then in your vstest task, you can specify the test search folder to $(build.artifactstagingdirectory)
Related
At the end of my pipeline I want to copy the bin directly to a network share from which it can be used to deploy.
I see there are two possible task typed that could do this:
copy files that makes a task: CopyPublishBuildArtifacts#1; or
_ copy and publish build artefacts_ that makes a CopyPublishBuildArtifacts#1.
And this publish is different to dotnet publish?
Which one should I pick and why?
They appear to have identical parameters.
What is the # for?
Azure pipeline yml: publish or file copy?
The task CopyPublishBuildArtifacts is deprecated. If you're using Team Foundation Server 2017 or newer, we recommend that you use Pipeline Artifacts.
And if you want to know the different between publishbuildartifacts vs publishpipelineartifact, you could check below thread for the details:
What is the difference between Build Artifact and Pipeline Artifact tasks?
And this publish is different to dotnet publish?
The answer is yes. The dotnet publish task is to serve the specific project. Its function is similar to that we choose the Publish option for net core project in Visual Studio.
But we could specify the folder or files to publish for the publishbuildartifacts or publishpipelineartifact task.
Which one should I pick and why?
We recommend to use the publishpipelineartifact task if you just want to copy the bin directly to a network share.
You could check the reason from here:
For build artifacts, it's common to copy files to $(Build.ArtifactStagingDirectory) and then use the Publish Build Artifacts task to publish this folder. With the Publish Pipeline Artifact task, you can just publish directly from the path containing the files.
By default, the Download Pipeline Artifact task downloads files to $(Pipeline.Workspace). This is the default and recommended path for all types of artifacts.
File matching patterns for the Download Build Artifacts task are expected to start with (or match) the artifact name, regardless if a specific artifact was specified or not. In the Download Pipeline Artifact task, patterns should not include the artifact name when an artifact name has already been specified. For more information, see single artifact selection.
What is the # for?
The role of # is to specify the version of the task. For example, #1 is to use the version 1.0 of the task.
What is the correct way to run automated UI tests by a self-hosted agent?
I tried to add a tests step in the release pipeline but it's not working because the agent cannot find the DLLs with tests (they are in a few separate projects)
##[warning]No test assemblies found matching the pattern: **\Test.UI.dll,!**\*TestAdapter.dll,!**\obj\**.
Currently, the release pipeline is simple: one artifact from the build pipeline and one stage with the following steps:
1. IIS Web App Deploy
2. IIS Web App Manage
3. VsTest: tests are selected using Test assemblies option
No test assemblies found matching the pattern.
It seems that the .dll files don't exist in the artifact or under the path of the release agent. You may need to share more information about the Pipeline. (e.g. build agent, pipeline definition and vstest task definition)
Before this, you can refer to the following steps for troubleshooting.
First of all, you need to make sure that the .dll files exist in the build artifacts.
You could check this in Build Summary -> Artifacts. You could download it and check the files in the artifact.
If the files don't exist, you could add a Copy files task before the Publish Artifacts task.
For example:
- task: CopyFiles#2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
SourceFolder: '$(agent.builddirectory)'
TargetFolder: '$(build.artifactstagingdirectory)'
enabled: false
Then the "VsTest" task will find the files in $(System.DefaultWorkingDirectory) by default(No customization). In release pipeline, the path is equals to C:\agent\_work\rx\a (e.g. C:\agent\_work\r1\a)
Since you are using the self-hosted agent , you could directly check the files in the target path on your local machine.
If you couldn't find the target files, you may need to modify the search folder or Test files path.
You also could check the file path in the Release Pipeline log -> Download Artifacts Step.
I'm trying to add a 'Publish Test Results' task into my Azure DevOps release pipeline, however, it looks like when I try to publish the .trx file, it's not looking in the correct folder and tries to parse an invalid file format (I'm assuming this is because it can't find the TestResults folder). I can see my file being created here in the Visual Studio Test task logs:
2020-02-19T21:28:57.6557476Z Vstest.console.exe exited with code 0.
2020-02-19T21:28:57.6557819Z:Completed test execution
2020-02-19T21:28:57.6640479Z Test results files: C:\agents\vm1-1_work_temp\TestResults\vm1$_vm1_2020-02-19_21_28_31.trx
However, in my Publish Test Results task logs, I get this error:
2020-02-19T21:28:59.7249456Z [command]C:\agents\vm1-1_work_tasks\PublishTestResults_0b0f01ed-7dde-43ff-9cbb-e48954daf9b1\2.164.3\modules\TestResultsPublisher.exe #C:\agents\vm1-1_work_temp\d793cb80-535e-11ea-9ab4-8f1d738f183d.txt
2020-02-19T21:29:00.5600855Z ##[warning]Failed to parse result files: Invalid file format.
This is what my Test Run and Publish Test Results tasks look like....can anyone point out what I am doing wrong here? I've seen people say that I don't need to add this task, but I am unable to see the Test Results tab in the pipeline, I can only see the .trx file attached to the task (see below).
TestResultsFormat is an alias for the testRunner input name. It seems you are using VSTest testRunner, so in Publish Test Results task, you should choose VSTest in TestResultsFormat.
I am fairly new to Azure Build pipelines, but I am having issues finding the answer to this.
When I build my artifact, the results include my server code files (vb and cs). How do I construct a build pipeline where the artifacts that are dropped are only the files I need to publish a site? Meaning, I want to exclude vb and cs files, but include necessary dll's and html/java script files.
You're publishing the wrong thing as an artifact. You're probably specifying $(Build.SourcesDirectory) or $(System.DefaultWorkingDirectory) as the root folder for your artifacts.
Look at your build step. Are you specifying an output directory as an MSBuild argument? If not, specify one. Specifically, $(Build.ArtifactStagingDirectory). So you'd pass the MSBuild argument /p:OutDir=$(build.artifactstagingdirectory)
Then publish $(Build.ArtifactStagingDirectory) instead of whatever folder you're currently publishing.
I'm following a learning course on plural-sight and he shows an artifact with cfg folder and json file within that folder(outside of the packge.zip file) but I cant figure out how he managed to configure his build process to get that file there.
How do I achieve this and where should i go to learn more about package files how they are made?
Everything in the "drop" folder gets included in the default "Publish Build Artifacts" Task, just add your files in the drop folder (or subfolders there).
The variable with the path is called: $(Build.ArtifactStagingDirectory)
This images shows a newly created "Publish Build Artifacts" task:
Something similar is probably creating your artifact, check for it in your build definition.