【问题标题】:error CloudServices077: Need to specify the physical directory for the virtual path 'Web/' of role错误 CloudServices077:需要为角色的虚拟路径“Web/”指定物理目录
【发布时间】:2016-07-19 06:08:35
【问题描述】:

我有一个包含许多项目的大型解决方案文件。包括三个 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:需要为角色WebService的虚拟路径'Web/'指定物理目录。

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

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

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

我什至不知道我想为物理目录放什么。

为了增加更多的混乱,我发现如果我只使用 Build 目标 MSBuild 解决方案,然后使用 Publish 目标 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 的情况下有何不同。 IE。使用 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.

【问题讨论】:

    标签: azure msbuild azure-sdk-.net


    【解决方案1】:

    虽然这篇文章很旧,但以防万一有像我这样的人在尝试在 Microsoft Azure 云服务中添加多个网站时也在寻找错误“需要指定虚拟路径的物理目录”的解决方案,我想分享一下我是如何解决的。

    我们只需要修改一个文件,即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>
    

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

    https://cuteprogramming.wordpress.com/2015/08/25/azure-cloud-service-say-hi-to-paas了解更多信息。


    所以现在,如果我想为同一个 Web 角色再添加一个新网站,我只需要再添加一个 &lt;Site&gt; 元素,如下所示。

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

    这里的常见错误是忘记为&lt;Site&gt;元素添加physicalDirectory,然后会抛出上面的错误“Need to specify the physical directory for the virtual path”

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

    所以要回答上面的议程问题,也许您可​​以尝试将属性物理目录添加到您的&lt;Site&gt;。希望对您有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-29
      • 2010-11-17
      • 1970-01-01
      相关资源
      最近更新 更多