Skip to content

Commit

Permalink
Merge pull request #605 from KevinMartin/patch-3
Browse files Browse the repository at this point in the history
Fix Content Types created by Mono
  • Loading branch information
anaisbetts committed Feb 27, 2016
2 parents 3a208fc + c0a3e95 commit 53fe066
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Squirrel/ContentType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ namespace Squirrel
{
internal static class ContentType
{
public static void Clean(XmlDocument doc)
{
var typesElement = doc.FirstChild.NextSibling;
if (typesElement.Name.ToLowerInvariant() != "types") {
throw new Exception("Invalid ContentTypes file, expected root node should be 'Types'");
}

var children = typesElement.ChildNodes.OfType<XmlElement>();
for (var child in children)
{
if (child.GetAttribute("Extension") == "")
{
typesElement.RemoveChild(child);
}
}
}

public static void Merge(XmlDocument doc)
{
var elements = new [] {
Expand Down
1 change: 1 addition & 0 deletions src/Squirrel/ReleasePackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ static internal void addDeltaFilesToContentTypes(string rootDirectory)
doc.Load(path);

ContentType.Merge(doc);
ContentType.Clean(doc);

using (var sw = new StreamWriter(path, false, Encoding.UTF8)) {
doc.Save(sw);
Expand Down

0 comments on commit 53fe066

Please sign in to comment.