4

I'm about to deploy a MVC4 site using the Web Deploy utility in VS2012. As I can't have direct connection to the server, I'm generating a 'Web Deploy Package' publish profile, which I upload and deploy using IIS > Import package option.

This is working all fine, but there is an exception. I need a Virtual Directory inside the site which points to another folder in server (where mobile data is uploaded). I can create this Virtual Directory without any problem, but everytime I deploy a package with a new version, the virtual directory gets removed and I have to remember to create it again.

What I'm trying to do is automate the creation process for this Virtual Directory, but I can't find out how to achieve it. The further I have gone is to find a PowerShell Cmdlet which allows me to create a new Virtual Directory, New-WebVirtualDirectory.

Is it possible to customize the package creation to run this cmdlet after deployment?

Farlop
  • 690
  • 1
  • 6
  • 20

1 Answers1

2

What you want to do is add a new MSBuild Task AfterTargets='MSDeployPublish'.

In order to do this you need to edit the csproj file and add a new Target with your powershell task.

It could look something like this:

<Target Name="PostPublishTarget" AfterTargets="MSDeployPublish">
   <Exec Command="$PowershellCmdHere"/>
</Target>

Find out more about doing powershell in MSBuild here

Community
  • 1
  • 1
Kyle C
  • 1,627
  • 12
  • 25