Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use Microsoft.TestPlatform.Portable in dotnet global tool #1948

Closed
rouke-broersma opened this issue Mar 10, 2019 · 7 comments
Closed
Assignees

Comments

@rouke-broersma
Copy link

Description

For our mutation testing framework we integrate with vstest using the translationlayer package. Since we cannot be sure vstest.console is available on the target system, we include Microsoft.TestPlatform.Portable to ensure the vstest binaries exist on the system. This used to work fine for dotnet cli extensibility tool but we are migrating to dotnet global tool (for dotnet full framework support) and the portable package seems to not be installed with the dotnet global tool on the target system. Can anyone provide some guidance as to how we can use the portable package to make vstest available to our dotnet global tool package?

@ShreyasRmsft
Copy link
Member

ShreyasRmsft commented Mar 11, 2019

Can you please elaborate your setup?

where do you include this:

we include Microsoft.TestPlatform.Portable to ensure the vstest binaries exist on the system



From what i was able to understand:

Ideally if your mutation testing framework requires vstest.console as a dependency then it is better to add a nuget reference to https://www.nuget.org/packages/Microsoft.TestPlatform in your framework and ensure it is bundled along with your tool.

@ShreyasRmsft ShreyasRmsft self-assigned this Mar 11, 2019
@rouke-broersma
Copy link
Author

@ShreyasRmsft We only need vstest.console so we do not need the full set of binaries and we reference https://www.nuget.org/packages/Microsoft.TestPlatform.Portable

I don't seem to get the content of the package bundled with my tool, nor does nuget seem to restore the package on the target system when installing the dotnet core global tool even though it is listed as a dependency. I would appreciate some advice on how to best bundle vstest with our framework.

@ShreyasRmsft
Copy link
Member

@Mobrockers you will have to author a post build .targets file that copies the package from the packagecache folder to the bin folder.

@rouke-broersma
Copy link
Author

Thanks, we have implemented a similar solution.

@li-zhixin
Copy link

Are there any updates on this issue? I'm having the same problem, is Post Build Event the official solution, I think it's ugly. If so, can you give an example? The version of the package that references microsoft.testplatform.portable is dynamic and I don't know how to confirm the version number in Post Build Event

@rouke-broersma
Copy link
Author

@li-zhixin

I solved it like this:

I created a 'fake' ptoject file which contains the portable package as a dependency:

https://github.com/stryker-mutator/stryker-net/blob/v1.0/src/Stryker.Core/Stryker.Core/ToolHelpers/vstest.fakeproject.csproj

In the pipeline I have a restore step to restore this package to a specific folder:

https://github.com/stryker-mutator/stryker-net/blob/v1.0/azure-pipelines.yml#L261-L267

In our actual project csproj I added a wildcard embedded resources import for any .nupkg file that looks like it's microsoft testplatform portable:

https://github.com/stryker-mutator/stryker-net/blob/v1.0/src/Stryker.Core/Stryker.Core/Stryker.Core.csproj#L34

Then I made a helper class to deploy vstest portable from embedded resources to the temp folder on the target machine:

https://github.com/stryker-mutator/stryker-net/blob/v1.0/src/Stryker.Core/Stryker.Core/ToolHelpers/VsTestHelper.cs#L181

@li-zhixin
Copy link

@rouke-broersma Thank you for sharing, after reading I think I will finish this workround soon.
I understand that this will work, but I still want to be clear about the official attitude and whether this is officially recognized as a standard solution. In my understanding, this is a workround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants