Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit b7d181f

Browse files
add back support for VS 2013 solution format changes
1 parent b9aee1f commit b7d181f

3 files changed

Lines changed: 46 additions & 1 deletion

File tree

src/Main/SharpDevelop/Project/Solution.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ class Solution : SolutionFolder, ISolution
2020
DirectoryName directory;
2121
readonly IProjectChangeWatcher changeWatcher;
2222
readonly IFileService fileService;
23+
internal Version currVSVersion, minVSVersion;
24+
25+
static readonly Version DefaultVSVersion = new Version(12, 0, 20827, 3);
26+
static readonly Version DefaultMinVSVersion = new Version(10, 0, 40219, 1);
2327

2428
public Solution(FileName fileName, IProjectChangeWatcher changeWatcher, IFileService fileService)
2529
{
@@ -280,7 +284,9 @@ public void Save()
280284
try {
281285
changeWatcher.Disable();
282286
using (var solutionWriter = new SolutionWriter(fileName)) {
283-
solutionWriter.WriteFormatHeader(ComputeSolutionVersion());
287+
var version = ComputeSolutionVersion();
288+
solutionWriter.WriteFormatHeader(version);
289+
solutionWriter.WriteSolutionVersionProperties(version, currVSVersion ?? DefaultVSVersion, minVSVersion ?? DefaultMinVSVersion);
284290
solutionWriter.WriteSolutionItems(this);
285291
solutionWriter.WriteGlobalSections(this);
286292
}
@@ -307,6 +313,9 @@ SolutionFormatVersion ComputeSolutionVersion()
307313
if (project.MinimumSolutionVersion > version)
308314
version = project.MinimumSolutionVersion;
309315
}
316+
317+
if ((minVSVersion != null || currVSVersion != null) && version < SolutionFormatVersion.VS2012)
318+
version = SolutionFormatVersion.VS2012;
310319
return version;
311320
}
312321
#endregion
@@ -461,5 +470,13 @@ public override string ToString()
461470
{
462471
return "[Solution " + fileName + " with " + projects.Count + " projects]";
463472
}
473+
474+
public Version VSVersion {
475+
get { return currVSVersion; }
476+
}
477+
478+
public Version MinVSVersion {
479+
get { return minVSVersion; }
480+
}
464481
}
465482
}

src/Main/SharpDevelop/Project/SolutionLoader.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ ProjectLoadException Error(string message, params object[] formatItems)
6060
public void ReadSolution(Solution solution, IProgressMonitor progress)
6161
{
6262
ReadFormatHeader();
63+
ReadVersionProperties(solution);
6364

6465
// Read solution folder and project entries:
6566
var solutionEntries = new List<ProjectLoadInformation>();
@@ -158,6 +159,7 @@ public void ReadSolution(Solution solution, IProgressMonitor progress)
158159

159160
#region ReadFormatHeader
160161
static Regex versionPattern = new Regex(@"^Microsoft Visual Studio Solution File, Format Version\s+(?<Version>[\d\.]+)\s*$");
162+
static Regex ideVersionPattern = new Regex(@"((Minimum)?VisualStudioVersion)\s+=\s(?<Version>\d+\.\d+\.\d+\.\d+)");
161163

162164
public SolutionFormatVersion ReadFormatHeader()
163165
{
@@ -190,6 +192,24 @@ public SolutionFormatVersion ReadFormatHeader()
190192
NextLine();
191193
return version;
192194
}
195+
196+
void ReadVersionProperties(Solution solution)
197+
{
198+
Match match = ideVersionPattern.Match(currentLine);
199+
while (match.Success) {
200+
Version ideVersion = new Version(match.Result("${Version}"));
201+
switch (match.Groups[1].Value) {
202+
case "VisualStudioVersion":
203+
solution.currVSVersion = ideVersion;
204+
break;
205+
case "MinimumVisualStudioVersion":
206+
solution.minVSVersion = ideVersion;
207+
break;
208+
}
209+
NextLine();
210+
match = ideVersionPattern.Match(currentLine);
211+
}
212+
}
193213
#endregion
194214

195215
#region ReadSection

src/Main/SharpDevelop/Project/SolutionWriter.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ public void WriteFormatHeader(SolutionFormatVersion version)
5555
}
5656
writer.WriteLine("# SharpDevelop " + RevisionClass.Major + "." + RevisionClass.Minor);
5757
}
58+
59+
public void WriteSolutionVersionProperties(SolutionFormatVersion version, Version currVSVersion, Version minVSVersion)
60+
{
61+
if (version >= SolutionFormatVersion.VS2012) {
62+
writer.WriteLine("VisualStudioVersion = {0}", currVSVersion);
63+
writer.WriteLine("MinimumVisualStudioVersion = {0}", minVSVersion);
64+
}
65+
}
5866
#endregion
5967

6068
#region Sections

0 commit comments

Comments
 (0)