I meet with a lot of customers that have the same problems creating packages that can deploy to IIS successfully. Here is my 3 stage process.
- Create a web application (SampleWebApplication.sln), check it renders a page and then close Visual Studio
- Create a batch file at the same location as the sln file, lets say Package.bat and run it.
msbuild SampleWebApp.sln /p:DeployOnBuild=true;Configuration=Release;PackageLocation=c:\src\test\SampleWebApp.zip;DeployIisAppPath="Default Web Site\SampleWebApp"
- By supplying the DeployOnBuild property this is the only way to call the /t:Package on a solution – otherwise you would have to build the csproj instead.
- If you do not supply the DeployIisAppPath then inside the SampleWebApp.SetParameters.xml file you will see that the IIS Application is suffixed with _deploy which comes from the default Microsoft.Web.Publishing.targets
- If you do not supply the PackageLocation you will find that the output is in the obj\Release\Packages folder
3. Deploy it with msdeploy. Get a command prompt and invoke the batch file that is created for you
C:\src\test\SampleWebApp.deploy.cmd /Y /M:simian-work
All done, you should have a package that you can deploy to your server from a command line. Next we look at customising IIS a bit more.