错误CloudServices077:需要指定虚拟路径的物理目录' Web /'角色

时间:2016-03-31 00:54:53

标签: azure msbuild azure-sdk-.net

我有一个包含许多项目的大型解决方案文件。包括三个Azure Web角色项目。我们正在使用MSBuild来构建这样的解决方案:

<MSBuild
  Projects="$(ProductRoot)\Product.sln"
  Properties="Configuration=$(BuildConfiguration);OutputPath=$(OutputPath)\Product;OutDir=$(OutputPath)\Product\;TargetProfile=$(TargetProfile);CloudExtensionsDir=$(CloudExtensionsDir);ServiceHostingSDKInstallDir=$(ServiceHostingSDKInstallDir);AzureClientLibInstallDir=$(AzureClientLibInstallDir);GenerateProjectSpecificOutputFolder=true"
  Targets="Build;Publish"/>

但是,对于我们的Azure项目,这失败了: 错误CloudServices077:需要指定虚拟路径的物理目录&#39; Web /&#39;角色WebService。

该解决方案在Visual Studio 2015中构建良好。

我不明白为什么它会因此错误而失败。我们每个云项目中只有一个站点,不需要physicalDirectory。这是来自CSDEF:

<Sites>
  <Site name="Web">
    <Bindings>
      <Binding name="Endpoint1" endpointName="WebService" />
    </Bindings>
  </Site>
</Sites>

我甚至不知道我想为physicalDirectory提供什么。

为此添加更多混淆,我发现如果我只使用Build目标MSBuild解决方案,然后用发布目标MSBuild我的每个云项目(CCPROJ)文件,那么它工作正常!但我需要发布整个解决方案,而无需在MSBuild中管理单个项目。

我能够在互联网上找到的这个问题的唯一其他参考来自此博客条目: https://blogs.msdn.microsoft.com/tomholl/2011/10/19/updates-to-windows-azure-msbuild-post-for-sdk-1-5/ 它隐含地建议我可以通过指定PackageForComputeEmulator来解决这个问题。首先,我不知道我是否正确阅读,其次,即使我是,我也想了解构建的CSPKG文件在指定和不指定PackageForComputeEmulator时是如何不同的。即是否仍然可以安全地将它部署到生产环境中并设置了PackageForComputeEmulator?

如果有人知道我为什么会收到此错误并知道如何解决,我会很感激!

下面是来自MSBuild诊断版本的喷出,它给出了错误:

Target "Build" skipped. Previously built successfully.
Target "CorePublish" in file "C:\tfs\azure\2.8\Microsoft.WindowsAzure.targets" from project "C:\tfs\Product\WebService.Cloud\WebService.Cloud.ccproj" (target "Publish" depends on it):
Task "Message"
  CorePublish: PackageWebRole = True
Done executing task "Message".
Task "Message"
  Publishing starting...
Done executing task "Message".
Task "Message"
  RolePlugins       is 
Done executing task "Message".
Task "Message"
  Importedmodules is 
Done executing task "Message".
Task "Message"
  Publishing to 'c:\Build\Productapp.publish\'
Done executing task "Message".
Task "MakeDir"
  Creating directory "c:\Build\Productapp.publish\".
Done executing task "MakeDir".
Task "Message"
  TargetServiceDefinition is c:\Build\Product\WebService.Cloud\ServiceDefinition.csdef
Done executing task "Message".
Task "Message"
  TargetServiceConfiguration is c:\Build\Product\WebService.Cloud\ServiceConfiguration.cscfg
Done executing task "Message".
Task "Message"
  Roles is 
Done executing task "Message".
Using "CSPack" task from assembly "C:\tfs\azure\v2.8\bin\Microsoft.ServiceHosting.Tools.MSBuildTasks.dll".
Task "CSPack"
  Searching for imported module RemoteAccess at C:\tfs\azure\v2.8\bin\plugins\RemoteAccess\RemoteAccess.csplugin...
  Searching for imported module RemoteForwarder at C:\tfs\azure\v2.8\bin\plugins\RemoteForwarder\RemoteForwarder.csplugin...
C:\tfs\azure\2.8\Microsoft.WindowsAzure.targets(3003,5): warning : CloudServices68 : No TargetFrameworkVersion specified for role WebService. Using .NET framework v4.0 for packaging. [C:\tfs\Product\WebService.Cloud\WebService.Cloud.ccproj]
c:\Build\Product\WebService.Cloud\ServiceDefinition.csdef : error CloudServices077: Need to specify the physical directory for the virtual path 'Web/' of role WebService. [C:\tfs\Product\WebService.Cloud\WebService.Cloud.ccproj]
Done executing task "CSPack" -- FAILED.
Done building target "CorePublish" in project "WebService.Cloud.ccproj" -- FAILED.
Done Building Project "C:\tfs\Product\WebService.Cloud\WebService.Cloud.ccproj" (Publish target(s)) -- FAILED.

1 个答案:

答案 0 :(得分:0)

虽然这篇文章已经过时了,但万一有像我这样的人也在寻找错误的解决方案&#34;需要为虚拟路径指定物理目录&#34;在尝试在Microsoft Azure Cloud Service中添加多个网站时,我想分享我如何解决它。

我们只需要更改一个文件,即 ServiceDefinition.csdef

在开始之前,请确保您没有在自动生成的ServiceDefinition.csdef版本上进行编辑。这个错误在另一篇文章中分享:https://stackoverflow.com/a/17554795/1177328

我在ServiceDefinition.csdef下面有以下代码。

<Sites>
  <Site name="Web">
    <VirtualApplication name="admin" physicalDirectory="..\..\..\Admin" />
    <Bindings>
      <Binding name="Endpoint" endpointName="EndpointHttp" />
    </Bindings>
  </Site>
</Sites>

通过这样做,我将在管理文件夹中以不同方式访问该网站。例如,如果我的主要网站是http://www.mywebsite.com,那么上面的管理虚拟网络应用程序将在http://www.mywebsite.com/admin访问。

https://cuteprogramming.wordpress.com/2015/08/25/azure-cloud-service-say-hi-to-paas了解详情。

现在,如果我想在同一个Web角色中再添加一个新网站,我只需添加一个<Site>元素,如下所示。

<Site name="2ndWeb" physicalDirectory="..\..\..\2ndWeb">
    <Bindings>
      <Binding name="NewWebsiteEndpoint1" 
          endpointName="Endpoint1" hostHeader="www.mywebsite.com" />
    </Bindings>
</Site>

这里常见的错误是忘记为<Site>元素添加physicalDirectory,然后将错误抛出&#34;需要指定虚拟路径的物理目录&#34;

您可以在http://www.wadewegner.com/2011/02/running-multiple-websites-in-a-windows-azure-web-role了解有关在同一Web角色中添加三个或更多网站的详情。

因此,要回答上面的Agendum问题,也许您可​​以尝试将属性physicalDirectory添加到<Site>。希望它有所帮助!