I have a solution with some projects targeting net standard 2.0 and a console application project targeting netcore 2.1
I set as output folder "myFolder". Building from visual studio I get all dlls in :
- "myFolder\netstandard2.0"
- "myFolder\netcoreapp2.1"
I get the same using the "dotnet build" command. Now I need my console application's exe file. So i use "dotnet publish -c Release -r win-x64 MySolution.sln" command.
Now I get this new directory "myFolder\netcoreapp2.1\win-x64" where I find all dlls and the console application's exe file.
Not enough!
I find one directory more: "myFolder\netcoreapp2.1\win-x64\publish" where I find again all dlls and the console application's exe file.
I wonder which meaning they have. I read the command documentation but I didn't find my answer.
Anyone lights me up?
Per the documentation
dotnet publish -c Release -r win-x64 --output ./MyTargetFolder MySolution.sln
All you really need to understand to be able to successfully publish and deploy is that you need to
dotnet publish
and ensure that you have a Release configuration-c Release
, as well as any other required options on the command line.All of your files will be in the 'publish' subfolder e.g. ./bin/Release/[framework that your solution is targeting]/publish. The files contained here are everything that is needed for a running instance of your application/service. The
MySolution.dll
is the entry point for your app/service, and will automatically link to all of the other dependencies and configuration stored in the publish folder.To configure and deploy a running instance, you need to work out how to deploy all of those files to a server, and somehow configure something (e.g. a web server, runtime, service host ...) to call your
MySolution.dll
.Note that in your
dotnet publish
you're specifying-r
, which means that your application is targetted to run under 64 bit Windows, as opposed to a Linux distribution or OSX (which makes it less portable, but has the advantage of isolating your app from changes to an installed runtime on a server that you deploy it to.). That's why you're seeing an extra folderwin-x64
.Also you're explicitly building from the solution configuration specified by your solution file
MySolution.sln
, which is probably the most reliable thing to do as this will ensure that any projects used as dependencies by your solution (which is a typical good practice) will be included in the build/publish.