Build/Test Issues

Project load failure

Started by LucasT on 9,133 views

Hi,

I've successfully used NCrunch in a number of solutions so far (great product BTW), but I have one project which refuses to load (The Status column says "Load failure").

The Tests window shows the following stack trace:


System.Xml.XmlException: Name cannot begin with the '.' character, hexadecimal value 0x00. Line 1, position 2.
   at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
   at System.Xml.XmlTextReaderImpl.ParseQName(Boolean isQName, Int32 startOffset, Int32& colonPos)
   at System.Xml.XmlTextReaderImpl.ParseElement()
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
   at System.Xml.Linq.XDocument.Parse(String text, LoadOptions options)
   at nCrunch.Client.ComponentLoader.ParsedBuildXml..ctor(BuildXml buildXml, FrameworkVersion defaultFrameworkVersion)
   at nCrunch.Client.ComponentLoader.SnapshotComponentFactory.(FilePath )
   at nCrunch.Client.ComponentLoader.SnapshotComponentFactory.(ComponentBuildAnalysisResult )
   at nCrunch.Client.ComponentLoader.SnapshotComponentFactory.(ProcessorArchitecture )
   at nCrunch.Client.ComponentLoader.SnapshotComponentFactory.CreateSnapshotComponentFromXml(FilePath projectFilePath, BuildXml projectXml, FilePath solutionFilePath, String[] additionalFilesToIncludeAtSolutionLevel, Boolean isLoadedFromFile, ISnapshotConfig snapshotConfig, VisualStudioVersion vsVersion)


I'm using NCrunch 2.15.0.9 with VS 2013 Update 4.

I've tried to change several configuration options without success.

The projectFilePath parameter name made me look at the csproj and nchrunchproject files. Both are well-formed XML and don't contain NULL characters. Changing encodings didn't fix the issue either.

In case it matters, the failing project isn't a test project, but one of the assembles under test. It's a ReSharper plugin.
Hi,

Thanks for sharing this issue.

This problem is originating from the code responsible for loading the project XML into memory. This means that the source of the XML exception is actually the project file itself.

Something particularly strange about this is how Visual Studio is able to load a project file with an invalid XML structure. I would expect that before NCrunch would fail, VS should fail ... Can you tell me a bit more about this project? Does the XML inside the project file seem valid and well formed? Or is this a JSON based project file? (note that these aren't supported by NCrunch yet).
This post has been deleted.
The project is a C# library (so a standard XML MSBuild file), and I double-checked it's well-formed.
I tried to remove the BOM but it didn't change the outcome.

(my previous message was a mistake, the file was still locked by the hex editor, so VS didn't load it and NCrunch didn't complain).
OK, I finally fixed the problem.

The project imports a lot of third-party target files (specifically: the JetBrains SDK). Some of these files were encoded in UTF-16... without a BOM.
MSBuild loads them just fine, but XDocument seems unable to cope with them. This explains the \x00 byte error.

Adding a BOM to these files fixed the issue.

The problem here is that these files come from a NuGet package, so it'd be nice if NCrunch could support them.

Edited

LucasT wrote:OK, I finally fixed the problem.

The project imports a lot of third-party target files (specifically: the JetBrains SDK). Some of these files were encoded in UTF-16... without a BOM.
MSBuild loads them just fine, but XDocument seems unable to cope with them. This explains the \x00 byte error.

Adding a BOM to these files fixed the issue.

The problem here is that these files come from a NuGet package, so it'd be nice if NCrunch could support them.


Interesting. Thanks for letting me know about this. Maybe I can find a better way to load this XML so it doesn't bug out so badly. Can you share any more details about how the files were imported? Was this just using an <Import> tag?
Yes, it was an <Import> tag.

If you want to reproduce it, it's just a matter of: Install-Package JetBrains.ReSharper.SDK

Here's an example project file from another ReSharper plugin. Not all of the included files are UTF-16 without BOM, but most of them are.
Excellent, thanks! I'll see what I can do.

Post a reply

Log in to reply.