Reputation: 573
I have moved the docker file from *.csproj folder to .sln folder i.e., one level up. When I try to docker build using visual studio 2019, I get bellow error but same project docker build works from command prompt. Not sure what is causing visual studio 2019 to throw this error. Any help to solve this error would be helpful.
Error: No Dockerfile could be found. Please make sure you have a Dockerfile called 'Dockerfile' adjacent to the project file.
Docker build works from commands prompt :
Upvotes: 16
Views: 7609
Reputation: 1
In VS right click on the project, select "Add", then "Docker Support". VS will add the file, config and start downloading the required docker image files
Upvotes: -3
Reputation: 2984
You can specify the path to the Dockerfile using the DockerfileFile property.
Example csproj configuration:
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UserSecretsId>secretstuff</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>.</DockerfileContext>
<DockerfileFile>..\Dockerfile</DockerfileFile>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
Upvotes: 42