This is the v15+ version of the uSync command line util, it uses the ManagementAPI (and the uSync Maanagement API) to do the funky stuff without you having to install anything on the server.
dotnet tool install uSync.Cli --version 15.0.0-beta1
In this beta, we have plugged in the 'useful' things you might need from the command line.
rebuild indexes, models or caches, or run usync imports or exports.
uSync CommandLine: 15.0.0-beta1
Description:
Usage:
uSync [command] [options]
Options:
--version Show version information
-?, -h, --help Show help and usage information
Commands:
test Test command
user-current Fetch the user executing the commands
user-list List all users
cache-rebuild Rebuild the cache on the server
cache-reload Reload the cache on the server
models-rebuild Rebuild the models on the server
models-status Get the status of the models on the server
indexer-rebuild Rebuild the index on the server
indexer-list List the indexes on the server
healthcheck-list List the health checks on the server
healthcheck-group-list List the health check groups on the server
healthcheck-group-check Run a health check on the server
usync-settings List all settings
usync-import Import all items
usync-export Export all items
usync-ping Ping the Umbraco server until it responds
e.g
run an import
uSyncCli usync-import -s https://myserver.com/ --force
In the users section of Umbraco
create the api user and add them to the relevant group
Once you have created an API user , you will need to give them a client id and secret,
you will need both the client id and secret to connect via the command line.
you can add an appsettings.json to the root of the folder where you are running the uSync command line:
{
"uSync": {
"Command": {
"Secret": "[CLIENT_SECRET]",
"ClientId": "[CLIENT_ID]"
}
}
}or you can pass these on the command line. eg.
uSyncCli usync-ping -s https://localhost:44359 -s [client_secret] -k [client_id]
if you place the uSync:Command settings in the appsettings.json file of a site. then if you run the uSync command from within the site directory it will attempt to workout the server Url,
if will check :
- the command line
-sparameter - for a
uSync:Command:ServerUrlvalue in appsettings - for the UmbracoApplicationUrl value
Umbraco:CMS:WebRouting:UmbracoApplicationUrl - for the applicationUrl value in the
Properties\launchSettings.jsonfile.
if it finds one, it will use it as the server address.
if the settings are stored in the sites appsettings.json (or the enviroment or a key vault). then you can
use the uSync.Command.Setup package to automatically setup the API user for you.
"uSync": {
"Command": {
"AddIfMissing": true,
"ClientId": "[CLIENT_ID]",
"Secret": "[CLIENT_SECRET]"
}
}on boot the uSync.Command.Setup package will check to see if the clientId has been setup on your site.
if it hasn't it creates an API user with the clientId / secret.
you can also specify Email, Username and Name for the API account, but if you don't some will
be generated for you.
Warning
This isn't compuslary, and it does open you up to potential issues if someone gets access to your appsettings.json (although you might already be in trouble if this happens).


