resharper-unity: Project load failed due to Unicode issue

Hi,

I updated to the Rider 2018.2 release yesterday and now it looks like Rider can no longer open my Unity solution’s projects.

I get these errors in the log: `14:48 Project ‘Assembly-CSharp’ load failed: Die Projektdatei konnte nicht geladen werden. Keine Unicodebyte-Reihenfolgemarkierung. Es kann nicht zu Unicode gewechselt werden. E:\trunk\Assembly-CSharp.csproj at (0:0)

14:48 Project ‘Assembly-CSharp-firstpass’ load failed: Die Projektdatei konnte nicht geladen werden. Keine Unicodebyte-Reihenfolgemarkierung. Es kann nicht zu Unicode gewechselt werden. E:\trunk\Assembly-CSharp-firstpass.csproj at (0:0)

14:48 Project ‘Assembly-CSharp-Editor’ load failed: Die Projektdatei konnte nicht geladen werden. Keine Unicodebyte-Reihenfolgemarkierung. Es kann nicht zu Unicode gewechselt werden. E:\trunk\Assembly-CSharp-Editor.csproj at (0:0)

14:48 Project ‘Assembly-CSharp-Editor-firstpass’ load failed: Die Projektdatei konnte nicht geladen werden. Keine Unicodebyte-Reihenfolgemarkierung. Es kann nicht zu Unicode gewechselt werden. E:\trunk\Assembly-CSharp-Editor-firstpass.csproj at (0:0) `

(Rough translation: “The project file could not be loaded. No Unicode byteorder mark. Can not switch to Unicode.”)

I already tried to invalidate Rider’s caches, removed all Rider data from the Unity project (both .idea in the root as well as the plugin in Assets/Plugins/Editor), tried the “Sync C# Project” from Unity and of course restartet both Unity and Rider.

Anything else I could try? I really need to get this working again to properly continue my work 😃

Regards, Chris

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 37 (17 by maintainers)

Commits related to this issue

Most upvoted comments

Fix will be included in Rider 2018.2.1.

For a temporary workaround:

  1. Disable the Rider plugin auto-injection via Rider -> Settings ->Languages and Framework -> Unity Engine -> uncheck “Install or Update Rider plugin automatically”.
  2. Remove existing Assets\Plugins\Editor\JetBrains\JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll
  3. Unzip attached dll to the same location. JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll.zip

@van800 This solution worked for me. The precise thing you need to do in your Unity project’s Packages/manifest.json is:

{
  "dependencies": {
    ...
    "com.unity.incrementalcompiler": "0.0.42-preview.26",
    ...
  },
  "registry": "https://staging-packages.unity.com"
}

In other words, add the registry line to ensure you have the staging registry.

Tested in 2018.2.16f and Rider 2018.2.3

I got a comment from Unity team saying: fixed in 0.0.42-preview.26 on staging repository.

@van800 is correct. XDocument will save with utf-16 by default. A custom text writer can be defined to change this behavior. Like this for example:

public class UTF8StringWriter : StringWriter
{
	public override Encoding Encoding
	{
		get { return Encoding.UTF8; }
	}
}

[UsedImplicitly]
public static string OnGeneratedCSProject(string path, string contents)
{
	try
	{
		XDocument doc = XDocument.Parse(contents);
		StringWriter sw = new UTF8StringWriter();
		doc.Save(sw);
		return sw.ToString(); // Instead of doc.ToString()
	}
	catch (Exception e)
	{
		Debug.LogError(e);
		return contents;
	}
}

@julia-vaseva Just set it back to the autodetected MSBuild and it’s giving the errors again. Restarted Rider to get cleaner logs (looks like idea.log never gets reset though): logs-20180825-132134.zip

@van800 While that might fix the current issue I don’t see why it should be necessary to install all this custom stuff if that was never needed before the 2018.2 build. Unity provides the Mono libraries that Rider should use for lookup anyway (and I think it properly did before, at least never had any errors). So this looks like a “simple” regression on Rider’s side (or becoming more strict about an issue in Unity but even so that should be fixed on Rider’s / Unity’s side and not require the end user to fiddle with stuff 😉 ). Anyway, there’s both a 3.5 and 3.0 in both x86 and normal Program Files and the plugin is installed fine. The Unity preferences for Rider are the same as in your screenshot (it’s not listing any installed .NET versions though in the label). Did the Sync C# Project thing a bunch of times by now but it seems this is a static issue.

Hello, I reproduce on Rider2018.2.3 & Unity2018.2.14f1

JetBrains Rider 2018.2.3
Build #RD-182.4231.496, built on September 13, 2018
JRE: 1.8.0_152-release-1248-b8 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

I delete JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll and install the dll. https://github.com/JetBrains/resharper-unity/issues/727#issuecomment-416020746

My csproj has <?xml version="1.0" encoding="utf-16"?>

Rider 2018.2.1. is out with fix to this problem. Be sure to install new Rider, open solution in Rider. Rider will install new EditorPlugin Focus Unity and it will reload new EditorPlugin.