c# - 发布Web API时Dotnet发布不会创建文件夹

标签 c# asp.net docker dotnet-cli

我一直在尝试遵循多个(example)教程,以了解如何将asp.net Web API放置到Docker镜像上。并且几乎所有人都使用docker文件,在其中执行以下命令dotnet [csproj name] -c Release -o out,然后最终将信息从该文件复制到另一个文件夹。但是,我一直遇到找不到该文件夹​​的问题。因此,我决定在本地使用此命令,令我惊讶的是,从未生产出out文件夹,也未构建任何东西。

当我们查看itdotnet publish的文档时,我们可以看到它显示以下内容:

Packs the application and its dependencies into a folder for deployment to a hosting system.





-o|--output <OUTPUT_DIRECTORY> Specifies the path for the output directory. If not specified, it defaults to ./bin/[configuration]/[framework]/publish/ for a framework-dependent deployment or ./bin/[configuration]/[framework]/[runtime]/publish/ for a self-contained deployment. If the path is relative, the output directory generated is relative to the project file location, not to the current working directory.



是的,我已经尝试了here的几乎所有解决方案。

在我看来,该命令应该创建一个新文件夹,所有发布的文件都放入其中。所以我的问题是:我错了吗,或者这里有问题吗?该问题的解决方案是什么?

最佳答案

是的,它将创建输出文件夹,但是在.NET Core 3.0工具发布之前,所有非绝对路径都将相对于项目目录进行解释。

因此,直到3.0,dotnet publish subdir(project.csproj -o otherdir将创建一个subdir/otherdir目录。

另请注意,dotnet publish将在其输出中打印发布至的路径。

关于c# - 发布Web API时Dotnet发布不会创建文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52893528/

相关文章:

c# - 错误 TS1219 : Experimental support for decorators is a feature that is subject to change in a future release

ASP.NET 和 AJAX 线程

node.js - Windows 10下Docker上的Nodejs开发

docker - Jenkins Pipeline 和 Docker - 如何从容器归档文件

c# - 正在被另一个程序写入的同时读取文件(Windows)

c# - LINQ 连接字符串位置

c# - 使用 Hostable Web Core 的自托管 Web 应用程序

c# - ASP.net 在一个 ashx 文件中处理自定义文件扩展名的所有请求

Travis CI 中的 Docker 构建失败 - 模式中出现 "Error checking context: ' 语法错误”

c# - 使用正则表达式从 SQL 查询中提取表和列