开发者

About the leading newline in Visual Studio solution files

开发者 https://www.devze.com 2022-12-24 09:53 出处:网络
Sometimes, for unknown reasons, VS 2008 creates solution files led by a newline. Microsoft Visual Studio Solution File, Format Version 10.00

Sometimes, for unknown reasons, VS 2008 creates solution files led by a newline.


Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
[...]

This happened on various machines, and I have no idea why this is. A Google search did not yield any useful results.

开发者_如何学编程Now, why do I worry about this? Because I can't open these solutions in Windows Explorer. I have to open VS, select File -> Open -> Solution and it works fine. But to open solutions from within Explorer, I have to edit the sln file and remove the leading newline.

Edit: After Leom's suggestion I tested a few times and found that the issue is solely dependent on the leading newline.

Edit: Interesting: VS 2010 displays the same behavior the other way around: It only works with a leading newline! At least on some solutions - on other solutions it's exactly the same as with VS 2008. I'm confused.


I too have observed strange behaviour regarding opening .sln file from explorer.

  • If you save the solution file as UTF-8 or Unicode, start the .sln file with an empty line. Otherwise it will not open when double clicking.
  • If you save the solution file as ANSI, don't start the .sln file with an empty line. Otherwise it will not open when double clicking.

It seems the Visual Studio Version Selector doesn't trust the BOM and wants a leading new line, unless the file is in ANSI encoding, than the leading new line must be omitted.

You can see this yourself when doing a save as on the solution file and selecting a different encoding.

Could be some legacy stuff.


I too have a blank line in my solution files, but I do not have this issue.

I did some digging, it appears that solution files actually launch the Visual Studio Version Selector, and the first 2 lines (not sure if it the actual first 2 lines, or the first 2 lines of text) of the .sln file act as the input parameters for this selector.

There could have been a possible corruption of this executable.

In addition, you may try in Visual Studio Tools->Options->Environment->General and choose the "Restore File Assoications".


I too faced the same issue. I observed this scenario after doing a reverse merge using IBM rational clearcase. It introduced a blank line at the beginning of the ".sln" file during reverse merge. To resolve this I opened the sln file in an editor (i used VI) and removed the blank line and saved the file. Then the file opened up in visual studio with a double click.


I just renamed a few directories in my projects and manually edited the .sln file and it stopped automatically loading Visual Studio 2010.

I tried saving as UTF-8 with no success. However, removing the blank line at the beginning restored the ability to double click to open.

I don't understand, but hey it works for me now.


Visual Studio solution files, for unknown reason, have to start with empty line. Your problems are probably not related to presence/absence of new line, but to encoding -- if SLN file is edited outside VS, it may be saved without Byte Order Mark (BOM). Try opening SLN file in notepad and do Save As -> Select UTF-8 encoding.


I had an sln upgraded from VS2005 to VS2008, but it wouldn't open on double click (by default it opens with the Visual Studio Version Selector). I looked inside an existing VS2008 sln, and it had a leading newline, while the upgraded sln didn't have it. Added a leading newline to the upgraded sln and it opens just fine.

It appears that VS2008 uses "Microsoft Visual Studio Solution File, Format Version 10.00" with a leading newline and VS2005 uses "Microsoft Visual Studio Solution File, Format Version 9.00" without a leading newline, but the former's conversions of VS2005 sln to VS2008 sln doesn't take the addition newline into account.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号