1

I have a solution which includes a single NET Core 3.1 Web API project and several other projects which are NET Framework 4.8 Class Library projects.

In my build pipeline the solution builds without any problems, I have a very simple build, however I need output from this build such as test assemblies as well configuration files to be made available for my release pipeline. The reason is that my release pipeline is associated with Test Plans and Test Suites and is needed for running these test plans on demand.

In any when I publish artifacts from the build pipeline none of the test assemblies are included, the only things that get included are those files from the Web App which I do not need for my test purposes. I've read in a couple of different places that I could add the other projects as dependencies but that just doesn't seem right to me as those dependencies are really needed. Is there another way to have the build pipeline publish those other assemblies and files?

[UPDATE] Solution 1: One solution that I saw suggested elsewhere was to use the Copy files task to copy the assemblies to ${Build.ArtifactStagingDirectory} and then publish the artifacts but either it's not working or i'm doing something incorrectly. Here is my YAML definition for the 2 tasks:

task: CopyFiles@2
inputs:
Contents: '**'
TargetFolder: '${Build.ArtifactStagingDirectory}'

task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'tests'
publishLocation: 'Container'

FWIW in the CopyFiles log I do see that the files are getting copied, for instance:

Copying d:\a\1\s\test\BaseTest.cs to ${Build.ArtifactStagingDirectory}\test\BaseTest.cs

so cal cheesehead
  • 2,515
  • 4
  • 29
  • 50

1 Answers1

1

These test assemblies will not auto include when you only build your class library project and publish your artifacts in build pipeline directly.

----Solution 
    ----NET Core 3.1 Web API project
    ----NET Framework 4.8 Class Library project 1
    ----NET Framework 4.8 Class Library project 2
    ...
    ----Test Project (Reference Class Library Project)

If you build test project, it will auto include referenced Class Library Project. And when you publish the build artifacts, it will also include generated Test Assemblies.

Another possibility is you did not choose the right path to copy dlls, it's using path which under class library project not test project.

You need to copy the generated Test Assemblies to $(build.artifactstagingdirectory) first through Copy Files task and then publish with the artifact.

enter image description here

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • I tried the Copy and Publish tasks but it's either not working or what i suspect is more likely is that I'm not doing it correctly. I updated my question with my task definitions. For the time being i tried to just copy all the files to not screw around with regex. I do see that the files get copied to `to ${Build.ArtifactStagingDirectory}\...` but when I publish the artifact they are not included. – so cal cheesehead Aug 11 '20 at 14:31
  • Also i noticed, or it looks like, you have the build process in the release pipeline, is there a reason why? Or is it just an example? I thought the proper/correct way to do it was to have a build pipeline that makes the artifacts available to the release pipeline. – so cal cheesehead Aug 11 '20 at 16:42
  • 1
    According to your yaml file, it's not the same directory. You using '${Build.ArtifactStagingDirectory}' in your copy File task. It should be $(Build.ArtifactStagingDirectory). Please use `()` instead of `{}` . And then check it again – PatrickLu-MSFT Aug 12 '20 at 09:58