azure - 错误云服务077 : Need to specify the physical directory for the virtual path 'Web/' of role

标签 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:需要为角色WebService的虚拟路径“Web/”指定物理目录。

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

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

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

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

为了增加更多的困惑,我发现如果我只使用构建目标 MSBuild 解决方案,然后使用发布目标 MSBuild 我的每个云项目 (CCPROJ) 文件,那么它就可以正常工作!但我需要发布整个解决方案,而不需要在 MSBuild 中管理各个项目。

我在互联网上找到的关于此问题的唯一其他引用来自此博客条目: https://blogs.msdn.microsoft.com/tomholl/2011/10/19/updates-to-windows-azure-msbuild-post-for-sdk-1-5/ 它隐含地表明我可以通过指定 PackageForComputeEmulator 来解决这个问题。首先,我不知道我是否正确地阅读了它,其次即使我是正确的,我也想了解在指定和不指定 PackageForComputeEmulator 的情况下构建的 CSPKG 文件有何不同。 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.

最佳答案

虽然这篇文章很旧,但以防万一有人像我一样在尝试在 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 角色再添加一个新网站,我只需要再添加一个 <Site>元素如下。

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

这里常见的错误是忘记为<Site>添加physicalDirectory元素,然后会在“需要指定虚拟路径的物理目录”之上抛出错误。

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

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

关于azure - 错误云服务077 : Need to specify the physical directory for the virtual path 'Web/' of role,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36322374/

相关文章:

azure - 导入 bacpac 失败并显示 "does not contain QueryStoreStaleQueryThreshold"

javascript - d3.js 从 url 获取 JSON

msbuild - VS2013 - MSB3270 : Mismatch between the processor architecture - Fakes Framework

c# - Azure 表存储 SDK - 清空表

azure - 无法加载文件或程序集“Microsoft.WindowsAzure.ServiceRuntime,版本=2.0.0.0”

VS2015 中的 Azure 调试环境启动时崩溃

azure - 如何在 Azure 门户中的两个现有 VM 之间创建网络连接

azure - 如何使用 Arm 模板获取应用服务中的主体 Id?

azure - 如何通过命令行将 Web 部署包部署到 Azure 网站?

azure - 使用TFS构建服务器但不部署