jeudi 9 mars 2017

Reading an utf8 encoded xml file in C#: the stream solution

All is in the title.
using (Stream str = System.IO.File.Open(@"fileName.xml", FileMode.Open)) {
    XmlReaderSettings p = new XmlReaderSettings {
        DtdProcessing = DtdProcessing.Parse
    };
    using (XmlReader xr = XmlReader.Create(new StreamReader(str, Encoding.UTF8), p)) {
        XDocument xDoc = XDocument.Load(xr);
        // or
        //XElement xEl = XElement.Load(xr);
   
        //do your stuff here.
    }
}

mercredi 1 mars 2017

dotnet restore hangs then time out with 100000ms

Especially on W7/x64

I found the solution here: https://github.com/dotnet/cli/issues/1732.

For several people it seems to be related to network interface (VMWare, VirtualBox...). For me the following unleash the restore:
Using "procmon" I found something strange happening in the lock files in %TEMP%\NugetScratch. I deleted that folder and everything started to work again and CI builds now work perfectly.
Happy restore!