[英]Put dockerfile at top level folder of solution
I have a Visual Studio solution with two projects.我有一个包含两个项目的 Visual Studio 解决方案。 I would like to have the Dockerfile at the same level as my solution file (sln) instead of having it inside my API project (default behavior).
我想让 Dockerfile 与我的解决方案文件 (sln) 处于同一级别,而不是将它放在我的 API 项目中(默认行为)。 I have tried several options, even adding to my API project:
我尝试了几个选项,甚至添加到我的 API 项目中:
<PropertyGroup>
<DockerfileContext>../Dockerfile</DockerfileContext>
</PropertyGroup>
However, Visual Studio is complaining "Error CTC1023 No Dockerfile could be found. Please make sure you have a Dockerfile called 'Dockerfile' adjacent to the project file"但是,Visual Studio 抱怨“错误 CTC1023 No Dockerfile 可以找到。请确保您有一个名为 'Dockerfile' 的 Dockerfile 与项目文件相邻”
Is it possible to have Docker integration with Visual Studio and place dockerfile at sln level?是否可以将 Docker 与 Visual Studio 集成并将 dockerfile 置于 sln 级别?
Ok, I found the answer, will post it just in case someone face the same situation.好的,我找到了答案,会发布它以防万一有人遇到同样的情况。
I added the following attribute in the API project csproj file:我在 API 项目 csproj 文件中添加了以下属性:
<PropertyGroup>
<!--Other properties ... ->
<DockerfileFile>../Dockerfile</DockerfileFile>
</PropertyGroup>
Where ../Dockerfile is the relative path to the dockerfile from the main project.其中../Dockerfile是主项目中 dockerfile 的相对路径。 Now it works.
现在它起作用了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.