3

I don't want to delete and recreate a site I just want to be able to apply the entire config to it and override any settings that are different.

I backed up the site config with %windir%\system32\inetsrv\appcmd list site /config /xml > c:\sites.xml

This command throws an error:

appcmd.exe add site /in < c:\sites.xml
ERROR ( message:Failed to add duplicate collection element "mysite". )

Do I really have to break out ALL of my IIS configuration into separate appcmd commands or is there a way to apply the entire xml in one shot and only have it override settings?

I want to have a single xml template that I can push out to all my webservers hosting this site.

red888
  • 27,709
  • 55
  • 204
  • 392

2 Answers2

4

If you already exists installed sites then you must by have other ID for new site

<SITE SITE.NAME="NewSite" SITE.ID="1094096085" bindings="*" state="Started">

        <site name="NewSite" id="1094096085" serverAutoStart="false">

Else you get conflict by ID

  • An easy solution to add the same set of numbers to the end of every entry in your xml file. Look at your existing IIS sites to see what numbers are there, and then make sure your new numbers won't conflict. For me adding `00` to each one sufficed. – Mmm Oct 05 '22 at 20:56
0

You should try shared config

http://www.iis.net/learn/manage/managing-your-configuration-settings/shared-configuration_264

Regarding:

 ERROR ( message:Failed to add duplicate collection element "mysite". )

It seems that you can not add a website that already exist.

Why dont you delete it and add it again with the new configurations?

You can also try to modify only the relevant sections.

Alexander Meise
  • 1,328
  • 2
  • 15
  • 31
  • The duplicate isn't necessarily at the site (url) level. If you already have existing sites, but they aren't the same URLs, you can still run into conflicts with the "id" (`site.id`, and `id`). Changing those ids in your xml to something outside the range of your existing ids will solve it. – Mmm Oct 05 '22 at 20:50
  • it's been 6 years and I dont support this anymore, but thanks, someone else might find it useful. – Alexander Meise Nov 04 '22 at 10:50