我正在尝试将 VS2013 中的“发布到天蓝色”功能用于我的工作角色云服务项目。
我遇到的问题是,无论我将服务配置设置更改为什么,应用程序始终与Local
服务配置一起部署
我的 .azurePubxml:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AzureCredentials>{"ServiceManagementEndpoint":"https:\/\/management.core.windows.net\/","SubscriptionId":"redacted"}</AzureCredentials>
<AzureDeleteDeploymentOnFailure>False</AzureDeleteDeploymentOnFailure>
<AzureDeploymentLabel>MyWorkerRole</AzureDeploymentLabel>
<AzureDeploymentReplacementMethod>AutomaticUpgrade</AzureDeploymentReplacementMethod>
<AzureSlot>Staging</AzureSlot>
<AzureEnableRemoteDesktop>True</AzureEnableRemoteDesktop>
<AzureEnableWebDeploy>False</AzureEnableWebDeploy>
<AzureFallbackToDeleteAndRecreateIfUpgradeFails>False</AzureFallbackToDeleteAndRecreateIfUpgradeFails>
<AzureHostedServiceLabel>MyLabel</AzureHostedServiceLabel>
<AzureHostedServiceName>MyService</AzureHostedServiceName>
<AzureEnableIntelliTrace>False</AzureEnableIntelliTrace>
<AzureEnableProfiling>False</AzureEnableProfiling>
<AzureServiceConfiguration>Staging</AzureServiceConfiguration>
<AzureSolutionConfiguration>Staging</AzureSolutionConfiguration>
<AzureStorageAccountLabel>webstorage</AzureStorageAccountLabel>
<AzureStorageAccountName>webstorage</AzureStorageAccountName>
<AzureAppendTimestampToDeploymentLabel>True</AzureAppendTimestampToDeploymentLabel>
</PropertyGroup>
</Project>
如您所见,AzureServiceConfiguration
设置为Staging
。如果我查看构建的输出,我可以看到以下几行:
Target "ResolveServiceConfiguration" in file "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Windows Azure Tools\2.6\Microsoft.WindowsAzure.targets" from project "path-to.ccproj" (target "CoreResolveServiceModel" depends on it):
3> Task "Message"
3> Target Profile: Local
3> Task "Message"
3> Service Configurations: ServiceConfiguration.Staging.cscfg;ServiceConfiguration.Production.cscfg;ServiceConfiguration.Local.cscfg
3> Task "Message"
3> Looking for a service configuration file named: ServiceConfiguration.Local.cscfg
3> Task "FindInList"
3> Task "Message"
3> Source Service Configuration: ServiceConfiguration.Local.cscfg
3> Task "Message"
3> Target Service Configuration: bin\Staging\ServiceConfiguration.cscfg
最终结果是ServiceConfiguration.Local.cscfg
在部署中使用 而不是ServiceConfiguration.Staging.cscfg
.
起作用的是在 Development->Run/debug 下将设置更改为暂存Service Configuration
。
但是这个设置控制了我在本地运行应用程序时使用哪个配置文件,所以我自然不想乱用它。
此外,如果我使用该Project->Package...
选项并选择暂存,我会得到正确的包和生成的正确配置文件。我也尝试过从命令行使用 msbuild 手动构建,效果也很好。
尝试更新到 azure sdk 2.6,希望它能解决它,但没有区别。
还应该说我在我的网络角色项目中有这个工作。但由于外部原因,我不得不将工作角色拆分到自己的云项目中。
更新一些更多信息,我又仔细查看了构建日志,发现了这个:
1>------ Build started: Project: MyProject, Configuration: Debug Any CPU ------
1>Build started 6/5/2015 5:15:03 PM.
1>Building with tools version "12.0".
1>Target "_CheckForInvalidConfigurationAndPlatform" in file "C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets" from project "path_to_project.csproj" (entry point):
1>Task "Error" skipped, due to false condition; ( '$(_InvalidConfigurationError)' == 'true' ) was evaluated as ( '' == 'true' ).
1>Task "Warning" skipped, due to false condition; ( '$(_InvalidConfigurationWarning)' == 'true' ) was evaluated as ( '' == 'true' ).
1>Using "Message" task from assembly "Microsoft.Build.Tasks.v12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>Task "Message"
1> Task Parameter:Text=Configuration=Debug
1> Task Parameter:Importance=Low
1> Configuration=Debug
所以似乎两者都没有
<AzureServiceConfiguration>Staging</AzureServiceConfiguration>
<AzureSolutionConfiguration>Staging</AzureSolutionConfiguration>
来自 .azurePubxml 的文件实际上被用作构建脚本的输入。
一切似乎都归结为,如果不是从 .azurePubxml 文件中,Publish to Azure 函数从哪里提取其参数?