简体   繁体   English

将 dockerfile 放在解决方案的顶级文件夹中

[英]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.

相关问题 项目级别的Visual Studio解决方案文件夹 - Visual studio solution folder at the project level 为什么不建立解决方案级别的文件夹? - Why doesn't folder at solution level build? 在解决方案文件夹中,图标应该放在哪里? - In the solution folder, where should I put the icons? TFS在顶层文件夹上显示最新 - TFS Show Latest on Top Level Folder 如何在vs 2008中的解决方案级别添加现有文件夹? - How to add an existing folder on a solution level in vs 2008? VS Post Build Event,复制解决方案文件夹上一级? - VS Post Build Event, copy one level above solution folder? 如何将项目放在 Visual Studio 解决方案中的一个文件夹中 - How to put projects in one folder in a Visual Studio solution 如何使用子级按钮创建解决方案右键单击顶级菜单?(Visual Studio 扩展) - how to create a solution right click top-level menu with sub-level button?(visual studio extension) 在解决方案级别和项目级别提示路径中创建的 nuget 包文件夹无法找到它 - nuget packages folder is created in solution level and project level hint path not able to find it VS 2010:将XML的完整目录添加为链接到解决方案文件夹? (此级别不存在任何项目) - VS 2010: Add as Link a complete directory of XML to a solution Folder? (no project exists at this level)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM