We're using the (almost completley undocumented) 'public API' for Web Deploy 3 to create a .zip package of our website and then sync it to a server:
DeploymentBaseOptions destinationOptions = new DeploymentBaseOptions()
{
UserName = //username,
Password = //password,
ComputerName = //a server
};
using (var deploymentObject = DeploymentManager.CreateObject(DeploymentWellKnownProvider.Package, "C:/MyWebsitePackage.zip"))
{
deploymentObject.SyncParameters.Load(packageParametersFile); \\ contains some connection string information and nothing more.
DeploymentSyncOptions syncOptions = new DeploymentSyncOptions();
syncOptions.WhatIf = false;
deploymentObject.SyncTo(destinationOptions, syncOptions);
}
This code worked perfectly until we installed .NET 4.5 on our production and build servers and upgraded the project we are deploying to 4.5 also. Now we're getting the following error:
The application pool that you are trying to use has the 'managedRuntimeVersion' property set to 'v4.0'. This application requires 'v4.5'. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_APPPOOL_VERSION_MISMATCH.
Our server definately has .Net 4.5 installed and the and the IIS web site application pool version is '.NET Framework v4.0.30319' (I know it says v4 but .NET 4.5 is an 'in-place' upgrade and replaces 4.0 DLLs with the new version number .30319).
It is possible to resolve this issue when deploying via MSBuild.exe command line (not by creating a package but by syncing directly to a server) by adding the /p:VisualStudioVersion=11.0 flag (which causes a different web application targets file to be used which somehow allows deployment of a .NET 4.5 application).
Does anyone know why Web Deploy API complains like this and how I can resolve this error in the same way as the MSBuild solution?