I am using the following appcmd to add an autoStartProvider to the list of autoStartProviders:
appcmd.exe set config -section:system.applicationHost/serviceAutoStartProviders /+"[name='MyAutoStartup',type='PreWarmCache, MyAssembly, version=1.0.0.0, Culture=neutral, PublicKeyToken=null']" /commit:apphost
Running the script for the first time, everything works correctly. But when running the script for the second time it complains that "MyAutoStartup" already exists. I know I can clear out the collection by using:
appcmd.exe clear config -section:system.applicationHost/serviceAutoStartProviders -commit:apphost
but that would remove all keys, not just MyAutoStart.
Is there a way to only remove MyAutoStart if it is present?
After experimenting I found the following command worked:
Basically it is replacing the "/+" with a "/-"