'Mount a relative path with DockerfileRunArguments

I have an ASP.NET core project running on Docker Desktop on Windows and I want to use the <DockerfileRunArguments> in my .csproj to bind mount a file from the host. How can I mount a file with a relative path?

This is the structure of the project:

.
+-- source
|   +-- project
|   |   +-- file.json
|   |   +-- Dockerfile
|   +-- project2
|   +-- project3

This is what I've tried but it throws an error:

<DockerfileContext>..\..</DockerfileContext>
<DockerfileRunArguments>-v "$(pwd)/source/project/file.json":"/whatever/file.json"</DockerfileRunArguments>

If I try an absolute path the file is mounted just fine.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source