To get a trial key
fill out the form below
Team License (a basic version)
Enterprise License (an extended version)
* By clicking this button you agree to our Privacy Policy statement

Request our prices
New License
License Renewal
--Select currency--
* By clicking this button you agree to our Privacy Policy statement

Free PVS-Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

Message submitted.

Your message has been sent. We will email you at

If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

Unity projects analysis: the solution f…

Unity projects analysis: the solution file has two projects named "UnityEngine.UI"

Jun 09 2021

While PVS-Studio analyses a Unity project, one may stumble upon such an error: Error was encountered while trying to open solution file '...': The solution file has two projects named "UnityEngine.UI". This note discusses the reasons for this error and how to eliminate it.


PVS-Studio uses some third-party libraries, including Roslyn and MSBuild to check C# projects. We use Roslyn to parse code. MSBuild parses solution (.sln) and project (.csproj) files. Besides, MSBuild is the main .NET build system.

You may encounter the error above when you call the Microsoft.Build.Construction.SoltuionFile.Parse method to receive a SolutionFile instance. The method is in the external library for the analyzer (Microsoft.Build.dll), so we can't change its behavior directly.

If you look closer at the text representation of the .sln file, you can notice duplicates in it. Example: (IDs of project types are shorter to make the example more compact).


Note that this .sln file duplicates project names: UnityEngine.UI and Assembly-CSharp. Each instance corresponds to a unique project file. For example, these are UnityEngine.UI.csproj and UnityEngine.UI.Player.csproj for UntiyEngine.UI.

If you try to build this solution by MSBuild, you will see an already familiar error: Solution file error MSB5004: The solution file has two projects named "UnityEngine.UI".

Interestingly, Visual Studio and JetBrains Rider, unlike MSBuild, are able to build such projects. Apparently, they use a different build mechanism (maybe they parse the .sln file themselves).

Possible solutions

A possible solution is to change project settings. The Unity editor generates an .sln file with duplicates if the "Player projects" option is enabled. Disable it in the same Unity editor: Edit -> Preferences -> Player projects.


After that, you may need to regenerate project files. The "Regenerate project files" button below is right for this.

Then duplicates from the .sln file must disappear, and the analysis should work fine.

If this method does not help or is not suitable for you, please email us.


We strive to improve the analysis of Unity projects. If you encounter any problems or have any wishes, please feel free to write to us.

Popular related articles
Nintendo Switch: drop test of the Ryujinx emulator's source code

Date: Jun 30 2021

Author: Danila Karpov

Each generation, companies like Sony, Microsoft and Nintendo delight their consumers with new consoles and different games for them. Yet there is a caveat - some games exclusively run on their platfo…
Unicorns break into RTS: analyzing the OpenRA source code

Date: Aug 13 2020

Author: Nikita Lipilin

This article is about the check of the OpenRA project using the static PVS-Studio analyzer. What is OpenRA? It is an open source game engine designed to create real-time strategies. The article descr…
How the PVS-Studio analyzer began to find even more errors in Unity projects

Date: Jun 29 2020

Author: Nikita Lipilin

When developing the PVS-Studio static analyzer, we try to develop it in various directions. Thus, our team is working on plugins for the IDE (Visual Studio, Rider), improving integration with CI, and…
RunUO check by the PVS-Studio analyzer

Date: Feb 05 2020

Author: Ekaterina Nikiforova

This article covers the check of the RunUO project using the static PVS-Studio analyzer. RunUO is the emulator of server software for Ultima Online, the game that once won the hearts of many MMORPG f…
Play "osu!", but watch out for bugs

Date: Jan 10 2020

Author: Sergey Khrenov

Hi, all of you collectors of exotic and plain bugs alike! We've got a rare specimen on our PVS-Studio test bench today – a game called "osu!", written in C#. As usual, we'll be looking for bugs, anal…

Comments (0)

Next comments
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site.
Learn More →