问题
I've read many posts, documentation pages etc. regarding WebDeploy via VS2012 and via command line.
In all of the deployment scenarios, I noticed that the destination site should already exist on the destination machine (IIS).
Is there an option to create a package that creates the site if it doesn't exist on the destination (hosting) machine?
回答1:
The appHostConfig
provider will create a site on the remote server. It comes with a million caveats on setting the remote bindings and physical path, so test it in a local environment first. You'll also need to be admin (obviously).
Since you are using VS2012 to perform your publish (as opposed to msdeploy directly). You should be able to automatically create the website by doing the following:
- Run Visual Studio 2012 as administrator
- Ensure that "Use Local IIS Server" is set in project properties
- Ensure that "Project Url" is correct (and, if a virtual directory, does not end in a
/
) - Declare
<IncludeIisSettings>true</IncludeIisSettings>
inside a<PropertyGroup>
in your publish profile
It should then include appHostConfig
in the deployment.
If you want to also create the application pool, you'll need to enable AppPoolExtension
in your publish profile:
<PropertyGroup>
<PublishEnableLinks>AppPoolExtension</PublishEnableLinks>
</PropertyGroup>
来源:https://stackoverflow.com/questions/12725777/can-we-create-a-new-web-site-using-ms-webdeploy