Can you automate a D365 FO deployment package creation?

I am a build engineer for my company and I am looking to integrate our D365 FO solution into our build process. Now I am able to compile the solution successfully but I understand that the way to create a deployment is through Visual Studio using the Dynamics 365 > Deploy > Create Deployment Package wizard. Now my question is can this process be automated via some command line tool or perhaps additional switches for msbuild, etc?

Don’t waste time with building everything from scratch - F&O already supports automated builds for years.

It used to require deploying a build VM from LCS, but now you can use even the hosted agent (check out this for instructions). Also, some release-related tasks have been recently added - you can let Azure DevOps to deploy packages to LCS Asset Library and apply them to environments.