Anders Lindén
Anders Lindén

Reputation: 7321

Cannot compile xml resource with mgcb

I am trying to add a xml resource with some level data in my monogame application. But when I try to run, I am getting an error.

The command "dotnet mgcb /quiet /@:"C:\projectpath\Content.mgcb" /platform:Windows /outputDir:"C:/projectpathpath/Content" /intermediateDir:"C:/projectpath/Content" /workingDir:"C:projectpath/Content/"" exited with code 1.

MGCB Editor:

enter image description here

levels.xml:

<?xml version="1.0" encoding="UTF-8"?>
<XnaContent>
    <Asset Type="Lib.Models.Levels">
    <levels>
        <level num="1" rule="multiban">
            <board>
<![CDATA[
31110
11111
11111
11121
11111
]]>
            </board>
            <cubes>
    <![CDATA[
00000
00020
00010
03000
00000       
]]>
            </cubes>
        </level>
    <levels>
    </Asset>
</XnaContent>

and a class in my project

Levels.cs:

using System.Collections.Generic;
using System.Xml.Serialization;

namespace Lib.Models
{
    public class Level
    {
        [XmlAttribute("num")]
        public int Number { get; set; }

        [XmlAttribute("rule")]
        public string Rule { get; set; }

        [XmlElement("board")]
        public string Board { get; set; }

        [XmlElement("cubes")]
        public string Cubes { get; set; }
    }

    [XmlRoot("levels")]
    public class Levels
    {
        [XmlElement("level")]
        public List<Level> Level { get; set; }
    }
}

Code that I try to load the levels with (but will never be reached):

var levels = Content.Load<Levels>("levels");

Upvotes: 0

Views: 36

Answers (0)

Related Questions