Playwright sharp Docker image issue

843 views Asked by At

I am trying to create a docker image of my playwright tests this is a .net 5 project using xunit.

When I try to start the docker image I get the following error

The specified task executable "sh" could not be run. System.IO.DirectoryNotFoundException: The working directory "/publish/.playwright/unix/native" does not exist. [/src/MyProject/MyProject.Core.csproj]

This is my dockerfile

FROM mcr.microsoft.com/dotnet/sdk:5.0 as build
WORKDIR /src
COPY ["MyProject.Core.csproj", ""]
RUN dotnet restore "MyProject.Core.csproj"
COPY . .
WORKDIR "/src"
RUN dotnet build "MyProject.Core.csproj" -c Debug -o /publish
    
FROM mcr.microsoft.com/playwright:v1.9.1-focal AS playwright

COPY --from=build /publish/ /app/
RUN chown -R pwuser:pwuser /app
run dotnet test /app/MyProject.Core.csproj

It seems to be coming from the playwrightSharp.targets file in the nuget package. I tried to comment out the targets, but I think it must be cached somewhere because it acts like its not commented out. Ieven tried deleting the targets file but still get the error:

/root/.nuget/packages/playwrightsharp/0.192.0/build/netstandard2.0/PlaywrightSharp.targets(18,5): error MSB6003:

It seems like the /root would be within the docker image? I dont know docker enough to even know where to look.

Any help would be appreciated! Thanks

1

There are 1 answers

0
Joe Beams On BEST ANSWER

It seems I was using an depreciated nuget package called Playwright, when I uninstalled and installed Microsoft.Playwright it worked as expected.