Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy won't my generated .sln file open in Visual Studio 2010?
    primarykey
    data
    text
    <p>I'm dealing with a fairly large C++ code base. The code base is normally intended to be compiled under Linux, using custom build scripts and makefiles. I'm porting the code into Visual Studio, which as anyone who's used Visual Studio would agree, is a pain to do manually. </p> <p>My own looking has been kind of fruitless, so I started writing my own utility in Qt to analyze the codebase and generate a solution file and accompanying <code>.vcxproj</code> files. I've been using the <code>QUuid</code> class to generate GUIDs for each of the projects, and I'm using <code>QTextStream</code> to write the <code>.sln</code> file.</p> <p>Now, here's the problem: When I open the generated <code>.sln</code> file, I see the following errors. <img src="https://i.stack.imgur.com/0gOTt.png" alt="The selected file is not a valid solution file"> <img src="https://i.stack.imgur.com/6SPjb.png" alt="The system can not find the file specified"></p> <p>I'm currently trying to generate a solution that I've already manually created within the Visual Studio IDE. I've compared my generated <code>.sln</code> file against the the one Visual Studio created, and apart from the projects appearing in a different order and the GUIDs not matching (obviously), I can't spot a difference. I'm including a simplifed example of my problem here.</p> <p><strong>Visual Studio generated this:</strong></p> <pre><code>Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mylib", "mylib\mylib.vcxproj", "{35BAFEEE-35FA-4313-AF67-AF8AB7458451}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {35BAFEEE-35FA-4313-AF67-AF8AB7458451}.Debug|Win32.ActiveCfg = Debug|Win32 {35BAFEEE-35FA-4313-AF67-AF8AB7458451}.Debug|Win32.Build.0 = Debug|Win32 {35BAFEEE-35FA-4313-AF67-AF8AB7458451}.Release|Win32.ActiveCfg = Release|Win32 {35BAFEEE-35FA-4313-AF67-AF8AB7458451}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal </code></pre> <p><strong>And I generated this:</strong></p> <pre><code>Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mylib", "mylib\mylib.vcxproj", "{A09FDB84-49CD-4C14-9D7D-D813D2D905EF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {A09FDB84-49CD-4C14-9D7D-D813D2D905EF}.Debug|Win32.ActiveCfg = Debug|Win32 {A09FDB84-49CD-4C14-9D7D-D813D2D905EF}.Debug|Win32.Build.0 = Debug|Win32 {A09FDB84-49CD-4C14-9D7D-D813D2D905EF}.Release|Win32.ActiveCfg = Release|Win32 {A09FDB84-49CD-4C14-9D7D-D813D2D905EF}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal </code></pre> <p>Here are my questions:</p> <ol> <li>What do these specifc error messages mean?</li> <li>Is there any way I can get more specific information on what's wrong with the <code>.sln</code> file?</li> <li>Is there something wrong with the GUIDs I'm generating? Should I be using the Visual Studio tool to create GUIDs?</li> <li>Is there some metadata or other invisible special sauce in the file that I'm missing?</li> </ol> <p>I'm pretty sure the issue isn't with text encoding--I used notepad to create a UTF-8 version of the <code>.sln</code> and tried opening that instead. </p> <p>In light of everything, it seems like my GUIDs are causing the issue--though I'm not sure how or why. </p> <h2>Update</h2> <p>The only major difference I noticed between these files was the file size. The two files differ by exactly 3 bytes, but I couldn't see anything in the file using my text editor. However, an article by <a href="http://www.joelonsoftware.com/articles/Unicode.html" rel="nofollow noreferrer">Joel Spolsky</a> got me thinking. There ain't no such thing as plain text--everything's just a representation of 1's and 0's, after all. </p> <p>I opened up the two files in a hex editor, and presto, I found the 3 bytes at the start of the Microsoft-generated file! (<code>0xEF, 0xBB, 0xBF</code>). These three bytes also appear in a Visual Studio 2008 solution I had lying around on a different machine. I could probably write my code to slip these bytes into the file before I start writing the solution, but that still begs the question:</p> <p><strong>What the heck are these bytes for, and why is Microsoft using them?</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload