Changing the build context is the way to go.
If you have a .net core project and you still want to use the Visual Studio UI to debug/publish the project with docker than you can change the context by adding the "DockerfileContext" to your projects .csproj:
<Project Sdk="Microsoft.NET.Sdk.Web"><PropertyGroup><TargetFramework>net6.0</TargetFramework><DockerDefaultTargetOS>Linux</DockerDefaultTargetOS><DockerfileContext>..\..\.</DockerfileContext></PropertyGroup> ...</Project>
Do not forget to change the paths in the Dockerfile accordingly.