How to set a virtual directory in IIS 6 to use .Net 2.0. IIS doens't have an API to set the version used. So you have to modify the meta-base. The easiest way to accomplish this is to import the meta-base changes from an XML file.
Here is an example dos command line to import...
cscript %systemroot%\system32\iiscnfg.vbs /import /merge /f .\metabase_merge_dot_net_2_0_50727.xml /sp /lm/W3SVC/1/Root/DotNet20Settings /dp /lm/W3SVC/1/Root/MyVirtualDirectory /children
It imports from "metabase_merge_dot_net_2_0_50727.xml" from DotNet20Settings into the virtual directory MyVirtualDirectory.
To create metabase_merge_dot_net_2_0_50727.xml I just exported the settings from a virtual directory that was setup for .Net 2.0. Then edited the xml. You have to keep the elements: configuration, MBProperty, IISGlobal (it contains the session key), IISWebVirtualDir. From IISWebVirtualDir delete everything except: Location and ScriptMaps. Then change the Location to the name you will use as the source: Location ="/LM/W3SVC/1/Root/DotNet20Settings"
Here is the code to run it from rake...
desc "set virtual directory to .Net 2.0"
task :config_myvirtdir_net20 do
sh "cscript #{ENV['systemroot'].chomp}\\system32\\iiscnfg.vbs /import /merge /f .\\metabase_merge_dot_net_2_0_50727.xml /sp /lm/W3SVC/1/Root/DotNet20Settings /dp /lm/W3SVC/1/Root/MyVirtualDirectory /children"
end