2

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?

Philipp Schmid
  • 359
  • 2
  • 6
  • 18

1 Answers1

3

After experimenting I found the following command worked:

appcmd.exe set config -section:system.applicationHost/serviceAutoStartProviders /-"[name='MyAutoStartup',type='PreWarmCache, MyAssembly, version=1.0.0.0, Culture=neutral, PublicKeyToken=null']" /commit:apphost

Basically it is replacing the "/+" with a "/-"

Michael
  • 31
  • 2