Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dotnet publish output folder?

The dotnet publish command published into the projects bin/netcoreapp2.2/Debug/publish folder. Where netcoreapp2.2 presumably changes with the dotnet version and Debug changes with whatever configuration the -c parameter specifies.

For CI/CD purposes this is clearly undesirable. Alternatively one can pass -o to pass an explicit output path, but again, in a CI/CI environment this path should be inside the project folder structure, e.g. something like:

dotnet publish -o publish

But, because the publish command globs up all files, it picks up previous publish attempts and recursively stores them. This can be mitigated by either cleaning the publish folder explicitly, and/or adding a to the csproj for the project but now there is a dependency between the build script and the csproj: if the publish path is changed in the build scripts for any reason without a corresponding csproj update things break.

So, the least fragile option seems to be to use the default output path as thats automatically excluded from globbing, but how to remove the version & configuration sensitivity? Is there a particularly safe way to get dotnet to tell my CI/CD environment what its output path for build / publish is?

like image 556
Chris Becke Avatar asked Jun 19 '19 09:06

Chris Becke


1 Answers

IMP: I do not have enough so reputation to add comment

refer : dotnet publish

you could use relative path with -o option and you may end up avoiding folder name with run-time, platform identification explicitly.

or why do not you consider using build command with publish profile where you can specify explicit path. but generally relative path is less error prone.

Hope this may help you !

like image 61
fedcbaeln Avatar answered Sep 19 '22 11:09

fedcbaeln