1

We are in the process of converting our NetFramework products to NETCore. In the older NetFramework product our integration tests are published to TFS as a build artifact. The release pipeline gets these artifacts, and runs silent installs, and then runs the tests using the visual studio test build step.

The newer product suite is now getting its integration tests converted. It's integration test assemblies are NETCore assemblies. I notice that I can either run these tests using vstest.console.exe, or dotnet test (either way). And I have manually verified this. However, I am at a loss as to how to run them efficiently and automatically in the TFS release pipeline.

Lets start with my "dotnet test" question. "Dotnet test" wants the ".csproj" source, and when I have manually supplied it and run this command from the command prompt it appears to need all of the other sources as if it is building the assemblies. Of course, I can supply all of the sources to the release pipeline, but really, is there no way to avoid that? After all, there is no "GetSources" step in the release pipeline, and while I can surely write my own, or supply the entire source repository as a build artifact, that seems very wasteful and seems wrong.

On the other hand, when I run the tests through vstest.console.exe, they first inform me of missing dependencies that are listed in the .deps.json file. Each time I run the test I "nuget install" them and copy the runtime folders to under the bin folder, and re-run, get the next error, and repeat. After 5 iterations all of the missing dependencies are there, and the tests run and pass. Is there some automatic means of getting a list of these missing dependencies and getting them all before attempting the test run?

Or is there some other means of getting a NETCore integration test to run in the TFS release pipeline that I am missing? Something simpler, or more direct?

Thanks!

SteveSims
  • 535
  • 6
  • 19
  • In fact there is an issue with doing the "dotnet test" getsources idea. Between the time that the build completes and the release process gets sources, the sources can change. When that happens the tests don't actually run on the sources that were built, unless a snapshot of all of the sources are published as an artifact. – SteveSims Jul 16 '19 at 08:19

1 Answers1

2

Is there some automatic means of getting a list of these missing dependencies and getting them all before attempting the test run?

AFAIK, to run .NET Core tests in release pipeline, we could add a Publish Build Artifacts task at the end of our Build Pipeline to publish folder with test project into artifacts and make the Release Pipeline pick up the published artifact.

Then in release pipeline add two .NET Core steps:

  • Command: restore, Path: path to your test.csproj
  • Command: test, Path: path to your test.csproj, Arguments: --no-build -c Release

Check this thread for some details.

Update:

SteveSims pointed in the comment:

The key point I did not understand that the sub-links provided me is that there is a "dotnet publish" command that resolves the missing dependencies. Therefore in the build pipeline, before I attached the binaries as an artifact, I did a dotnet publish to that folder. TaDah! the necessary runtimes folder appeared, and it was wrapped up and attached as an artifact for the release pipeline to use.

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • 1
    Thanks, but as mentioned in the original post, the hope is that the complete sources would not be needed in the release pipeline. There is no seamless GetSources pipeline release step, and a roll-my-own get sources might not guarentee the sources were the same as the build's sources unless I had the build publish all of the sources needed as an artifact. -- a rather large artifacts package. There is no .csproj there to supply as an argument to the dotnet restore, or dotnet test commands. – SteveSims Jul 16 '19 at 10:18
  • 1
    Actually that thread has links that are stumbling me to the obvious answer that I have missed. I will post back soon, and if this works out, I'll credit this answer. – SteveSims Jul 16 '19 at 10:19
  • @SteveSims, "There is no .csproj there to supply as an argument to the dotnet restore, or dotnet test commands. " What you said is correct, I realize it after I post the answer too. I will investigate it again. And I look forward to your answer too. – Leo Liu Jul 16 '19 at 10:22
  • Ok, I am marking this as the accepted answer, but will add the derived details here. The key point I did not understand that the sub-links provided me is that there is a "dotnet publish" command that resolves the missing dependencies. Therefore in the build pipeline, before I attached the binaries as an artifact, I did a dotnet publish to that folder. TaDah! the necessary runtimes folder appeared, and it was wrapped up and attached as an artifact for the release pipeline to use. – SteveSims Jul 16 '19 at 13:46
  • Thanks for the response. – SteveSims Jul 16 '19 at 13:46
  • 1
    By the way, feel free to edit your answer to include these derived details directly. It might help someone who does not read the comments. Apologies for not knowing what information to supply in the original post. – SteveSims Jul 16 '19 at 13:49
  • @SteveSims, I will update it when I back to the office. – Leo Liu Jul 16 '19 at 14:28