Jul 1, 2010 at 7:54 PM
Edited Jul 1, 2010 at 8:02 PM
I'm attempting to add a task to my MS Build project that will remove a virtual directory (if it exists) from the default web site and then create the virtual directory again (also on the default web site). We had been using the MSBuild.Community
tasks and IIS6, but they haven't been updated to support IIS7.
The MSBuild Extension Pack help doesn't include an example for the AddVirtualDirectory task action and there doesn't appear to be a way to delete a virtual directory - the only task action for deletes appears to only delete a site.
If I add the following to my MSBuild targets file and call the DeployToWeb target:
<ApplicationPath>/Default Web Site</ApplicationPath>
<MSBuild.ExtensionPack.Web.Iis7Website TaskAction="Delete" Name="MyVdir" ContinueOnError="true"/>
I get the following output from MSBUILD:
C:\projects\Test\buildtest.targets (,): warning : The website: MyVdir was not found on: BRE0106
Adding VirtualDirectory: /MyVdir to: /Default Web Site
MSBUILD (,): warning : NullReferenceException: Object reference not set to an instance of an object. [C:\projects\Test\buildtest.targets]
MSBUILD (,): warning : [C:\projects\Test\buildtest.targets]
The first error makes sense as I haven't successfully created the virtual directory yet, and I'm not expecting that the Delete task action will work to delete a virtual directory anyway.
But given the limited help documentation, especially for AddVirtualDirectory, and minimal information in the error, I honestly have no idea what I'm doing wrong to add a virtual directory to the default web site.
Any assistance would be appreciated.