see docs for build number:
https://learn.microsoft.com/en-us/azure/devops/pipelines/process/run-number?view=azure-devops
note: use the build number values to environment variable(s) supplied to the build by DevOps to add the build number to code. if you manually want to control the build number rather than DevOps, just define the env variable statically.
.net core by default allow setting the assemble info from build:
https://learn.microsoft.com/en-us/dotnet/standard/assembly/set-attributes-project-file