【问题标题】:Error while using command line tool cspack使用命令行工具 cspack 时出错
【发布时间】:2016-04-05 13:04:04
【问题描述】:

执行 cspack 命令时出现以下错误 “错误 CloudServices051:XML 规范无效:命名空间 'http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition' 中的元素 'WebRole' 的内容不完整。预期的可能元素列表:命名空间 'http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition' 中的 'Sites'。”

<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="CloudService1"      xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="WebRole1" enableNativeCodeExecution="false">
<InputEndpoints>
 <InputEndpoint name="HttpIn" protocol="http" port="80"/>
</InputEndpoints>
    <ConfigurationSettings/>
</WebRole>
</ServiceDefinition>

【问题讨论】:

  • 由于几乎没有文档,我在尝试使用 CSPack 时没有任何运气。你想完成什么?
  • 我刚刚开始在 Azure 中编写 hello world 程序,并开始关注一本书。在书中作者建议使用命令行工具,因为它可以让初学者很好地了解技术。无论如何都会切换到MSVS,但在此之前想调试这个问题

标签: azure


【解决方案1】:

我从你的例子中猜想你正在使用 Sririam Krishnan 的Programming Windows Azure一书。

这本书于 2010 年 5 月出版。本书提供了一个损坏的示例,或者从那时起向 Azure 框架引入了一些重大更改。

下面是第 51 页中的 ServiceDefinition.csdef 文件,已修改为与 Azure SDK v2.8 一起使用:

<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="CloudService1" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" > 
  <WebRole name="WebRole1" enableNativeCodeExecution="false">
    <InputEndpoints>
      <InputEndpoint name="HttpIn" protocol="http" port="80" />
    </InputEndpoints>
    <ConfigurationSettings />
    <!-- This sites node was not included in the example -->
    <Sites>
        <Site name="TokenSite" physicalDirectory="htmlwebsite">
            <Bindings>
                <Binding name="BindingOne" endpointName="HttpIn" />
            </Bindings>     
        </Site>
    </Sites>
  </WebRole>
</ServiceDefinition>

添加的是Sites 节点,其中包含一个站点。 physicalDirectory 属性必须指向包含 html 文件的文件夹。在我添加 Sites 节点之前,cspack 实用程序失败了。

有趣的是,如果您阅读了 Azure Online Documentation 中的 Sites 元素(最后更新于 2015 年 4 月 15 日),它明确表示:

如果您未指定站点元素,则您的 Web 角色将作为旧 Web 角色托管,并且您只能将一个网站托管在您的 Web 角色中。 ...这个元素是可选的,一个角色只能有一个站点阻止。 (我的斜体)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-04
    • 1970-01-01
    • 2013-10-30
    • 2012-07-05
    • 1970-01-01
    • 1970-01-01
    • 2018-01-03
    相关资源
    最近更新 更多