microsoft / playwright-dotnet

.NET version of the Playwright testing and automation library.
https://playwright.dev/dotnet/
MIT License
2.47k stars 235 forks source link

Could we exclude the tool build task from the package? #1078

Closed WeihanLi closed 3 years ago

WeihanLi commented 3 years ago

As the title, could we exclude the tool build task from the package?

Currently, we run our apps in docker container, when run dotnet build in the docker it'll cause the driver install, but we do not need to install the drivers when we build, we'll install in our program before use playwrite

Hope it can be removed, because it'll increase our docker build elapsed time, more worse when bad network

kblok commented 3 years ago

we'll install in our program before use playwright.

Could you tell me how are you doing that?

WeihanLi commented 3 years ago

Just call Playwrite.InstallAsync() in Program.cs or Startup.Configure to install

kblok commented 3 years ago

You can remove that line of code and let dotnet build do that for you. I think it's better to lose some time on build than on runtime.

WeihanLi commented 3 years ago

It's not so friendly for docker build, the recommend dockerfile now is using multi-stage building, the package installed during dotnet build step is not necessary, and it will not copy to the runtime docker image, so the runtime image will still have to install the browser drivers, it means we have to install the drivers twice before we use it in docker environment

WeihanLi commented 3 years ago

Wondering that if we could add some switch or parameter for install the drivers during build task?

kblok commented 3 years ago

If you use the official Docker image (https://github.com/microsoft/playwright-sharp/blob/a388277f82a1398348179000f737c983c03ff8cd/README.md#using-playwright-in-docker), that step in the build would just pass through.

WeihanLi commented 3 years ago

I'm using a custom docker image on top of mcr.microsoft.com/dotnet/core/aspnet:3.1

kblok commented 3 years ago

There are some recipes here https://github.com/microsoft/playwright-sharp/issues/982

WeihanLi commented 3 years ago

Oh, thanks