dotnet publish output folder?
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 !
Related videos on Youtube
Chris Becke
Updated on June 04, 2022Comments
-
Chris Becke over 1 year
The
dotnet publish
command published into the projectsbin/netcoreapp2.2/Debug/publish
folder. Wherenetcoreapp2.2
presumably changes with the dotnet version andDebug
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?
-
Chris Becke over 4 yearsabsolute paths are out as the build runner server has multiple runners, so potentially two builds might try and use the same "c:\publish" folder at the same time. relative paths are undesirable as they get recursively globbed, and while this can be fixed I'm unhappy with the invisible dependency as this violates the principal of 'least surprise'.
-
fedcbaeln over 4 yearsdid you try publish profile :docs.microsoft.com/en-us/aspnet/core/host-and-deploy/…
-
fedcbaeln over 4 yearsoption 1: did you try publish profile : Publish Profiles this may solve both getting ride of default folder names and relative path , where you can specify absolute path. but end of the day we have to specify the path either by relative or absolute. option 2: you could store absolute path using CI/CD pipeline variable or environmental variable, and use them in commands - seems like code/project does not know about publish path