private PublishContext CreatePublishContext(
string name,
string slot,
string location,
string affinityGroup,
string storageServiceName,
string deploymentName,
CloudServiceProject cloudServiceProject)
{
string serviceName;
// If the name provided is different than existing name change it
if (!string.IsNullOrEmpty(name) && name != cloudServiceProject.ServiceName)
{
cloudServiceProject.ChangeServiceName(name, cloudServiceProject.Paths);
}
// If there's no storage service provided, try using the default one
if (string.IsNullOrEmpty(storageServiceName))
{
storageServiceName = Subscription.GetProperty(AzureSubscription.Property.StorageAccount);
}
ServiceSettings serviceSettings = ServiceSettings.LoadDefault(
cloudServiceProject.Paths.Settings,
slot,
location,
affinityGroup,
Subscription.Name,
storageServiceName,
name,
cloudServiceProject.ServiceName,
out serviceName
);
// Use default location if not location and affinity group provided
serviceSettings.Location = string.IsNullOrEmpty(serviceSettings.Location) &&
string.IsNullOrEmpty(serviceSettings.AffinityGroup) ?
GetDefaultLocation() : serviceSettings.Location;
PublishContext context = new PublishContext(
serviceSettings,
Path.Combine(GetCurrentDirectory(), cloudServiceProject.Paths.CloudPackage),
Path.Combine(GetCurrentDirectory(), cloudServiceProject.Paths.CloudConfiguration),
serviceName,
deploymentName,
cloudServiceProject.Paths.RootPath);
context.ServiceProject = cloudServiceProject;
return(context);
}