Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dotnet publish doesn't create folder when publishing web api

I've been trying to follow multiple (example) tutorials about how to place an asp.net Web API onto a docker image. And in pretty much all of them use a docker file in which the following command is done dotnet [csproj name] -c Release -o out and then eventually copy the information from this to another folder. however, I kept getting issues with the folder out not being found. So I decided to use this command locally, and to my amazement found out that no out folder is ever produced, nor anything is built.

When we look at the documentation of the dotnet publish on it we can see it says the following:

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

and

-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.

And yes, I've tried pretty much every solution from here.

Which seems to me that this command should make a new folder in which all the published files are placed into. So my question is: Am I mistaken, or is there an issue at play here and what is the solution for the issue?

like image 635
Dennis.Verweij Avatar asked Aug 31 '25 16:08

Dennis.Verweij


1 Answers

Yes it will create the output folder, however until .NET Core 3.0 tooling, any non-absolute path is interpreted relative to the project's directory.

So until 3.0, dotnet publish subdir(project.csproj -o otherdir will create a subdir/otherdir directory.

Also note that dotnet publish will print the path it publishes to in its output.

like image 90
Martin Ullrich Avatar answered Sep 02 '25 05:09

Martin Ullrich