0

希望有人可以在这里提供帮助。我正在尝试对自托管的流浪盒进行版本控制,因此无需使用 Vagrant Cloud。

我创建了以下元数据文件:

{
  "description": "How about this",
  "name": "Graphite",
  "versions": [
    {
      "version": "1.8",
      "providers": [
        {
          "name": "virtualbox",
          "url": "http://desktopenvironments/Graphite/Graphite_1.8.box"
        }
      ]
    }
  ]
}

这直接取自 vagrant(有些缺乏)文档,位于:http ://docs.vagrantup.com/v2/boxes/format.html 。

运行 vagrant add (直接从磁盘获取包含此文件的盒子文件)时,我得到:

The metadata associated with the box 'graphite' appears corrupted.
This is most often caused by a disk issue or system crash. Please
remove the box, re-add it, and try again.

任何有关为什么会发生这种情况的帮助将不胜感激。

4

1 回答 1

1

正在从我编写的 ac# 应用程序生成我的元数据文件,使用 UTF8 进行文本编码。这还不够。您需要使用没有 BOM 的 UTF8。一旦删除了字节顺序标记,它就可以工作 100 秒。

var settings = new JsonSerializerSettings() { ContractResolver = new LowercaseContractResolver() };
string json = JsonConvert.SerializeObject(metadata, Formatting.None, settings);
var utf8WithoutBom = new System.Text.UTF8Encoding(false);
using (var sink = new StreamWriter(outputFilePath, false, utf8WithoutBom))
{
    sink.Write(json);
}
于 2015-05-28T14:38:35.090 回答