Skip to content

Instantly share code, notes, and snippets.

Created May 16, 2018 17:50
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jbevain/9fb03a1893b176eec93082bc15103bd9 to your computer and use it in GitHub Desktop.
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using UnityEngine;
using UnityEditor;
using SyntaxTree.VisualStudio.Unity.Bridge;
public class ProjectFileHook
// necessary for XLinq to save the xml project file in utf8
class Utf8StringWriter : StringWriter
public override Encoding Encoding
get { return Encoding.UTF8; }
static ProjectFileHook()
ProjectFilesGenerator.ProjectFileGeneration += (string name, string content) =>
// parse the document and make some changes
var document = XDocument.Parse(content);
var ns = document.Root.Name.Namespace;
.First(x => x.Name.LocalName == "PropertyGroup")
.Add(new XElement(ns + "NoWarn", "649"));
// save the changes using the Utf8StringWriter
var str = new Utf8StringWriter();
return str.ToString();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment