Publishing to $(Build.ArtifactStagingDirectory) is fine. There are several ways to do it, so here's one:
- Add a Docker task after the publish, configured to "Build"
- Set the "Build Context" in the task to $(Build.ArtifactStagingDirectory). That's the root path Docker will use for commands like COPY in a Dockerfile.
- Commit a Dockerfile to your repo, and set the Dockerfile path in the task to match its location
Set up the Dockerfile like this (I'm assuming .NET Core 2.2 here):
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2
WORKDIR /app
COPY . .
ENTRYPOINT ["dotnet", "myAppNameHere.dll"]
Because you've set the Docker Build Context to $(Build.ArtifactStagingDirectory), where your app has been published, the COPY command will use that as a "current working directory." The translation of the COPY is "copy everything in $(Build.ArtifactStagingDirectory) to the /app folder inside the container."
That'll get you a basic Docker container that simply contains your pre-built and published app files.