13

I want to use visual studio 2017 as a default editor

I have visual studio 2012 and visual studio 2017 I want to use visual studio 2017 as default.I opened project(.sln) and select visual studio version selector.It choose visual studio 2012

I used "Always use the selected program to open this kind of file" option.I choose visual studio 2017 but it does not open project

If I open visual studio 2017 and click open solution and navigate project it open project succcessfully

user1688401
  • 1,851
  • 8
  • 47
  • 83
  • Please see this question and answers: https://stackoverflow.com/questions/19513306/how-to-force-a-solution-file-sln-to-be-opened-in-visual-studio-2013 – Dabbas Oct 21 '17 at 18:11
  • in .sln file, should I change "Microsoft Visual Studio Solution File Format Version 12.00 " with "Microsoft Visual Studio Solution File, Format Version 17.00" and change "# Visual Studio 2012" with "# Visual Studio 2017" – user1688401 Oct 21 '17 at 18:21
  • 3
    Everyone seems to be missing the point of this question: We just want to have all SLNs open in VS 2017 by default when you double-click it in Windows File Explorer. If it's older, sure, it can convert it. – csrowell Mar 08 '18 at 19:58
  • I looked into this more. To troubleshoot, I renamed my VS 2015 (what the default gets set to on my machine when trying to pick 2017) to devenv.exe.old and tried setting 2017 to be the default again. I then got a "The program you have selected cannot be associated with this file type. Please choose another program." error. After trying the method at these links I am still unable to get .SLN files to always open in 2017 by default: https://support.microsoft.com/en-us/help/2159999/sometimes-you-can-not-associate-a-program-with-an-extension-in-windows and https://superuser.com/questions/977271 – csrowell Mar 13 '18 at 18:46
  • Well, you can ignore my previous comments. I had screwed up the VisualStudio.sln.xxxxxxxx entry in HKEY_CLASSES_ROOT which caused the odd behavior. After correcting it, I am able to "Always use the selected program to open this kind of file". – csrowell Apr 19 '18 at 18:59

4 Answers4

10

The simplest solution is:

  1. Open the solution file using Visual Studio 2017
  2. Select the solution file in Solution Explorer
  3. Select File and Save Solution.sln As...
  4. Overwrite the existing solution file.

With this actions, the solution should open with VS17

Lord_Curdin
  • 957
  • 1
  • 14
  • 27
  • 6
    Even simpler: select the solution file and Ctrl+S (no need to save as…) – Daniel Liuzzi Dec 27 '17 at 21:19
  • Select Solution file means you click the very top item with your solution name and a window symbol next to it. Then you can simply do File -> Save MySolutionName – Girl Spider May 21 '21 at 18:41
8

Even simpler: right click on a .sln file and select "Open with" then choose "default program", then select VS 2017. That sets the default application .sln files will open with in the future.

2

I had a similar issue where opening a .sln was launching the wrong VS version, on Windows 7. None of the usual fixes worked: Windows won't let me change the default program for .sln. Editing the version number within the sln (or resaving it) had no effect. Editing "HKLM...\App Paths" in registry did not work.

The solution:

In regedit

  • Find HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.sln
  • Delete key "UserChoice"
  • Now right-click a .sln file, pick "Properties" and Windows will let you change the default "Opens with" program.
Jem
  • 2,255
  • 18
  • 25
1

Open the .sln file in a text editor and change the version in the "# Visual Studio" comment to 15, as so:

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15

After that change, Microsoft Visual Studio Version Selector will open the solution in Visual Studio 2017.

The third line of the .sln file sets a VisualStudioVersion build variable. This variable's value does not affect which version is opened, but it is passed along to MSBuild in case you have any version-specific logic there.

MikeTV
  • 645
  • 6
  • 14
  • This was working but suddenly mine are now opening in VS 2019 despite still having this at the top of the .sln. – xr280xr Oct 27 '20 at 18:40
  • @xr280xr Can you check to see if .sln is still associated with Microsoft Visual Studio Version Selector? Could be the file type got directly associated with Visual Studio 2019. – MikeTV Oct 29 '20 at 15:04
  • yes, it's still associated and opens with 2019 even when I choose Open With... Visual Studio Version Selector. The .sln icon shows the 15 and the tooltip when I hover the cursor over it shows "Visual Studio 15". 2019 seems to have taken over all of my VS 2017 solutions. – xr280xr Oct 30 '20 at 20:32