The first you need to know is that the error that doesn't allow you to compile your project, is generally not the IDE (Visual Studio) fault but some dependency in your project e.g a NuGet package or yours, because you may have manually changed a file of your project and something went wrong. In this case, the only way to know what's happening is to debug your project in the old school way, searching in the log by yourself.
In order to access the log of your project in Visual Studio 2017, you will need to follow these steps:
1. Remove .vs folder of your project
In this article, the Name of our project will be CefsharpExample, it's a WinForms project pretty simple. The first you need to do in order to identify the error in your project, is to delete the hidden .vs folder located in the root of your project. The purpose of this folder is to move machine- and user-specific files to a central location, therefore it will be recreated automatically if needed.
Important
By default, you can't see the hidden folders in the File Explorer of Windows, therefore don't forget to check the Show Hidden Items property in your system.
Just delete the folder and proceed with the next step.
2. Start Visual Studio through the DCP for VS 2017
The Developer Command Prompt for Visual Studio automatically sets the environment variables that enable you to easily use .NET Framework tools and allows you to change them as you wish. The Developer Command Prompt is normally installed with full or community editions of Visual Studio.
You can access it quickly with the search bar in the Start Menu of Windows:
Then run the following instructions on it (one after another):
set TRACEDESIGNTIME=true
devenv
Then your command prompt would look like:
And it should start automatically Visual Studio. Once it starts, start the solution of your project, theoretically the error should still exists, now we need to access the log file.
3. Search for the .log file of your project
The log file is located in the Temp folder of the system, usually C:\Users\<username>\AppData\Local\Temp
(you can quickly access to the folder by typing %appdata%
in the search menu of Windows). The file that you need have ends with .designtime.log, however there will be probably a lot of them. The correct log should have the name of your project at the beginning, which should make the search easier.
Tip
To boost your search, the log file should contain the name of your project as filename, so you can use the search menu in the \AppData\Local\Temp
folder.
When you find the file, open it with any text editor. In most of the cases, the log should provide a sort of hint that will help you to know what's failing. Generally, the error can be found at the end of the file, in our case the error were the following:
Build FAILED.
C:\Users\sdkca\documents\visual studio 2017\Projects\CefSharpExample\packages\CefSharp.Common.55.0.0\build\CefSharp.Common.targets(4,5):
error : CefSharp.Common will work out of the box if you specify platform (x86 / x64). For AnyCPU Support see https://github.com/cefsharp/CefSharp/issues/1714
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.29
Our error was generated by a missconfiguration in the NuGet package of CefSharp. In your project, the problem may be something similar, for example it's looking for some file or SDK that's not installed, or some permissions were denied, etc. As specified in the repository of the Roslin C# Compiler, in case it seems to be a problem with Visual Studio itself, you might want to file a bug on the GitHub project , so a Visual Studio engineer will take a look. Make sure you provide the full log and if possible your project file, since they may need both to diagnose the problem.
Happy coding !