diff --git a/src/Assets/TestProjects/TestAppWithSlnAndReferenceToSingleCsproj/App.sln b/src/Assets/TestProjects/TestAppWithSlnAndReferenceToSingleCsproj/App.sln new file mode 100644 index 000000000000..1a6639b73db2 --- /dev/null +++ b/src/Assets/TestProjects/TestAppWithSlnAndReferenceToSingleCsproj/App.sln @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26006.2 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "App", "App\App.csproj", "{7072A694-548F-4CAE-A58F-12D257D5F486}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x64.ActiveCfg = Debug|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x64.Build.0 = Debug|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x86.ActiveCfg = Debug|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x86.Build.0 = Debug|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|Any CPU.Build.0 = Release|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x64.ActiveCfg = Release|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x64.Build.0 = Release|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.ActiveCfg = Release|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/Assets/TestProjects/TestAppWithSlnAndReferenceToSingleCsproj/App/App.csproj b/src/Assets/TestProjects/TestAppWithSlnAndReferenceToSingleCsproj/App/App.csproj new file mode 100644 index 000000000000..bde2ee936a4c --- /dev/null +++ b/src/Assets/TestProjects/TestAppWithSlnAndReferenceToSingleCsproj/App/App.csproj @@ -0,0 +1,12 @@ + + + + Exe + $(CurrentTargetFramework) + + + + + + + diff --git a/src/Assets/TestProjects/TestAppWithSlnAndReferenceToSingleCsproj/App/Program.cs b/src/Assets/TestProjects/TestAppWithSlnAndReferenceToSingleCsproj/App/Program.cs new file mode 100644 index 000000000000..b71a6fdb4110 --- /dev/null +++ b/src/Assets/TestProjects/TestAppWithSlnAndReferenceToSingleCsproj/App/Program.cs @@ -0,0 +1,13 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; + +class Program +{ + static void Main(string[] args) + { + Console.WriteLine("Hello from the main app"); + Console.WriteLine(Lib.Library.GetMessage()); + } +} diff --git a/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/App.sln b/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/App.sln new file mode 100644 index 000000000000..6165f20f171e --- /dev/null +++ b/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/App.sln @@ -0,0 +1,75 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32929.385 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "App", "App\App.csproj", "{7072A694-548F-4CAE-A58F-12D257D5F486}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lib", "Lib\Lib.csproj", "{D4ED07FD-E893-4D38-8E19-33C3027D687A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "First", "Multiple\First.csproj", "{F1383793-E608-49EA-A9BE-B7C26E94850B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Second", "Multiple\Second.csproj", "{5F64398F-08F6-4FDA-87DE-6F138AF81DC8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x64.ActiveCfg = Debug|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x86.ActiveCfg = Debug|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|Any CPU.Build.0 = Release|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x64.ActiveCfg = Release|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x64.Build.0 = Release|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.ActiveCfg = Release|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.Build.0 = Release|x86 + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Debug|x64.ActiveCfg = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Debug|x64.Build.0 = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Debug|x86.ActiveCfg = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Debug|x86.Build.0 = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Release|Any CPU.Build.0 = Release|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Release|x64.ActiveCfg = Release|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Release|x64.Build.0 = Release|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Release|x86.ActiveCfg = Release|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Release|x86.Build.0 = Release|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Debug|x64.ActiveCfg = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Debug|x64.Build.0 = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Debug|x86.ActiveCfg = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Debug|x86.Build.0 = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Release|Any CPU.Build.0 = Release|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Release|x64.ActiveCfg = Release|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Release|x64.Build.0 = Release|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Release|x86.ActiveCfg = Release|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Release|x86.Build.0 = Release|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Debug|x64.ActiveCfg = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Debug|x64.Build.0 = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Debug|x86.ActiveCfg = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Debug|x86.Build.0 = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Release|Any CPU.Build.0 = Release|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Release|x64.ActiveCfg = Release|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Release|x64.Build.0 = Release|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Release|x86.ActiveCfg = Release|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {69061246-1432-4C95-A7C9-B17C637C8639} + EndGlobalSection +EndGlobal diff --git a/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/App/App.csproj b/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/App/App.csproj new file mode 100644 index 000000000000..bde2ee936a4c --- /dev/null +++ b/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/App/App.csproj @@ -0,0 +1,12 @@ + + + + Exe + $(CurrentTargetFramework) + + + + + + + diff --git a/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/App/Program.cs b/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/App/Program.cs new file mode 100644 index 000000000000..b71a6fdb4110 --- /dev/null +++ b/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/App/Program.cs @@ -0,0 +1,13 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; + +class Program +{ + static void Main(string[] args) + { + Console.WriteLine("Hello from the main app"); + Console.WriteLine(Lib.Library.GetMessage()); + } +} diff --git a/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/Empty/README b/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/Empty/README new file mode 100644 index 000000000000..439cfe9c7a4a --- /dev/null +++ b/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/Empty/README @@ -0,0 +1,2 @@ +This directory is intentionally empty. + diff --git a/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/Lib/Lib.csproj b/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/Lib/Lib.csproj new file mode 100644 index 000000000000..c350d4032840 --- /dev/null +++ b/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/Lib/Lib.csproj @@ -0,0 +1,7 @@ + + + + netstandard1.4 + + + diff --git a/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/Lib/Library.cs b/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/Lib/Library.cs new file mode 100644 index 000000000000..71a4d48322c7 --- /dev/null +++ b/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/Lib/Library.cs @@ -0,0 +1,15 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; + +namespace Lib +{ + public class Library + { + public static string GetMessage() + { + return "Message from Lib"; + } + } +} diff --git a/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/Multiple/First.csproj b/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/Multiple/First.csproj new file mode 100644 index 000000000000..9f5c4f4abb61 --- /dev/null +++ b/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/Multiple/First.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0 + + + diff --git a/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/Multiple/Second.csproj b/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/Multiple/Second.csproj new file mode 100644 index 000000000000..9f5c4f4abb61 --- /dev/null +++ b/src/Assets/TestProjects/TestAppWithSlnAndReferencesToMultipleCsproj/Multiple/Second.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0 + + + diff --git a/src/Cli/Microsoft.DotNet.Cli.Sln.Internal/SlnFile.cs b/src/Cli/Microsoft.DotNet.Cli.Sln.Internal/SlnFile.cs index 15c970494ac4..4ef5a21467f5 100644 --- a/src/Cli/Microsoft.DotNet.Cli.Sln.Internal/SlnFile.cs +++ b/src/Cli/Microsoft.DotNet.Cli.Sln.Internal/SlnFile.cs @@ -37,7 +37,7 @@ namespace Microsoft.DotNet.Cli.Sln.Internal { - public class SlnFile + public partial class SlnFile { private SlnProjectCollection _projects = new SlnProjectCollection(); private SlnSectionCollection _sections = new SlnSectionCollection(); @@ -178,6 +178,7 @@ private void Read(TextReader reader) var sec = new SlnSection(); sec.Read(reader, line, ref curLineNum); _sections.Add(sec); + LoadConfigurations(sec); } else // Ignore text that's out of place { @@ -239,7 +240,7 @@ private void Write(TextWriter writer) } } - public class SlnProject + public partial class SlnProject { private SlnSectionCollection _sections = new SlnSectionCollection(); @@ -390,7 +391,7 @@ public class SlnSection { private SlnPropertySetCollection _nestedPropertySets; private SlnPropertySet _properties; - private List _sectionLines; + internal List _sectionLines; private int _baseIndex; public string Id { get; set; } @@ -507,7 +508,7 @@ private SlnSectionType ToSectionType(int curLineNum, string s) String.Format(LocalizableStrings.InvalidSectionTypeError, s)); } - private string FromSectionType(bool isProjectSection, SlnSectionType type) + internal string FromSectionType(bool isProjectSection, SlnSectionType type) { if (type == SlnSectionType.PreProcess) { @@ -633,7 +634,7 @@ internal void Write(TextWriter writer, string sectionTag) /// /// A collection of properties /// - public class SlnPropertySet : IDictionary + public partial class SlnPropertySet : IDictionary { private OrderedDictionary _values = new OrderedDictionary(); private bool _isMetadata; diff --git a/src/Cli/Microsoft.DotNet.Cli.Sln.Internal/SlnFileConfig.cs b/src/Cli/Microsoft.DotNet.Cli.Sln.Internal/SlnFileConfig.cs new file mode 100644 index 000000000000..d99f75f21991 --- /dev/null +++ b/src/Cli/Microsoft.DotNet.Cli.Sln.Internal/SlnFileConfig.cs @@ -0,0 +1,290 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// TBD - license to be updated + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Build.Evaluation; +using static System.Collections.Specialized.BitVector32; +using Microsoft.DotNet.Cli.Utils; +using System.Security.Permissions; +using Microsoft.DotNet.Cli.Sln.Internal.FileManipulation; +using NuGet.Versioning; +using System.Reflection; + +namespace Microsoft.DotNet.Cli.Sln.Internal +{ + public class ProjConfigPlatform + { + internal string _slnConfig; + private string _slnPlatform; + internal string _build; + private string _deploy; + private string _projConfig; + private string _projPlatform; + + public ProjConfigPlatform(string slnConfig, string slnPlatform, + string build, string deploy, string projConfig, string projPlatform, string line) + { + _slnConfig = slnConfig; + _slnPlatform = slnPlatform; + _build = build; + _deploy = deploy; + _projConfig = projConfig; + _projPlatform = projPlatform; + } + + public ProjConfigPlatform(ProjConfigPlatform pcp, string newSlnConfig, string createNewProjectConfig, string build=null) + { + _slnConfig = newSlnConfig; + _slnPlatform = pcp._slnPlatform; + if (string.IsNullOrEmpty(build)) _build = pcp._build; else _build = build; + _deploy = pcp._deploy; + if (createNewProjectConfig.Equals("y")) + _projConfig = newSlnConfig; + else + _projConfig = pcp._projConfig; + _projPlatform = pcp._projPlatform; + } + + public string PropertyKey() + { + return _slnConfig + "|" + _slnPlatform + "." + _build; + } + + public string PropertyValue() + { + return _projConfig + "|" + _projPlatform; + } + } + + public class SlnConfigPlatform + { + internal string _config; + internal string _platform; + public SlnConfigPlatform(string config, string platform) + { + _config = config; + _platform = platform; + } + + public SlnConfigPlatform(SlnConfigPlatform scp, string newconfig) + { + _config = newconfig; + _platform = scp._platform; + } + + public string PropertyKey() + { + return _config + "|" + _platform; + } + } + + public partial class SlnFile + { + //private string ActiveSlnConfig = ""; + //private string ActiveSlnPlatform = ""; + private const string SlnConfigPlatformsSectionId = "SolutionConfigurationPlatforms"; + private const string ProjConfigPlatformsSectionId = "ProjectConfigurationPlatforms"; + + private List _slnConfigs = new List(); + private List _slnPlatforms = new List(); + private List _slnConfigPlatforms = new List(); + internal void LoadConfigurations(SlnSection sec) + { + string Id = sec.Id; + + if (Id.Equals(SlnConfigPlatformsSectionId)) + { + LoadConfigurations(sec._sectionLines); + } + else if (Id.Equals(ProjConfigPlatformsSectionId)) + { + foreach (SlnProject project in _projects) + { + List projSectionLines = sec._sectionLines.FindAll( + delegate (string line) + { + return line.StartsWith(project.Id); + }); + + project.LoadConfigurations(projSectionLines); + } + } + } + public bool LoadConfigurations(List sectionLines) + { + foreach (string line in sectionLines) + { + int i = line.IndexOf('|'); + int j = line.IndexOf('='); + if (i != -1 && j != -1) + { + string config = line.Substring(0, i).Trim(); + string platform = line.Substring(i + 1, j - i - 1).Trim(); + SlnConfigPlatform entry = new SlnConfigPlatform(config, platform); + _slnConfigPlatforms.Add(entry); + + if (!_slnConfigs.Contains(config)) + _slnConfigs.Add(config); + + if (!_slnPlatforms.Contains(platform)) + _slnPlatforms.Add(platform); + } + } + return true; + } + + public void WriteConfigutations(string file = null) + { + Write(file); + } + + public void AddNewSlnConfig(SlnConfigPlatform scp, string newConfigName) + { + if (!_slnConfigs.Contains(newConfigName)) + _slnConfigs.Add(newConfigName); + + SlnConfigPlatform newscp = new SlnConfigPlatform(scp, newConfigName); + _slnConfigPlatforms.Add(newscp); + + string key = newscp.PropertyKey(); + _sections.GetSection(SlnConfigPlatformsSectionId).Properties.AddProperty(key, key); + } + + public bool AddNewSlnConfig(string newconfigname, string copyfromoldconfig = null, string createnewprojectconfig = null) + { + if(_slnConfigs.Contains(newconfigname)) + { + throw new GracefulException("ConfigureAddConfigAlreadyExists"); + } + + if (!string.IsNullOrEmpty(copyfromoldconfig) && !_slnConfigs.Contains(copyfromoldconfig)) + { + throw new GracefulException("ConfigureAddCopyFromDoesNotExists"); + } + + List slnconfigplatforms = _slnConfigPlatforms.FindAll(scp => scp._config.Equals(copyfromoldconfig)); + if (slnconfigplatforms.Count <= 0) + { + return false; + } + + foreach (SlnConfigPlatform scp in slnconfigplatforms) + AddNewSlnConfig(scp, newconfigname); + + foreach (SlnProject project in _projects) + { + List projconfigplatforms = + project._projConfigPlatforms.FindAll(pcp => pcp._slnConfig.Equals(copyfromoldconfig)); + + if (projconfigplatforms.Count <= 0) + continue; + + foreach (ProjConfigPlatform pcp in projconfigplatforms) + { + project._propSet = _sections.GetSection(ProjConfigPlatformsSectionId).NestedPropertySets.GetPropertySet(project.Id); + project.AddNewSlnConfig(pcp, newconfigname, copyfromoldconfig, createnewprojectconfig); + } + } + return true; + } + + public bool AddNewSlnPlatform(string newconfigname, string copyfromoldconfig = "", bool createnewprojectconfig = true) + { + return true; + } + + public bool AddNewProjConfig(string project, string newconfigname, string copyfromoldconfig = "", bool createnewslnconfig = true) + { + return true; + } + + public bool AddNewProjPlatform(string project, string newconfigname, string copyfromoldconfig = "", bool createnewslnconfig = true) + { + return true; + } + + } + + public partial class SlnProject + { + internal SlnPropertySet _propSet; + private List _projConfigs = new List(); + private List _projPlatforms = new List(); + internal List _projConfigPlatforms = new List(); + private const string ProjConfigPlatformsSectionId = "ProjectConfigurationPlatforms"; + public void AddNewSlnConfig(ProjConfigPlatform pcp, string newConfigName, string copyFromOldConfig, string createNewProjectConfig) + { + if (!_projConfigs.Contains(newConfigName)) + _projConfigs.Add(newConfigName); + + if (string.IsNullOrEmpty(copyFromOldConfig)) + { + //Add 2 entries, one for Activeconfig & Build.0 + ProjConfigPlatform newpcp = new ProjConfigPlatform(pcp, newConfigName, createNewProjectConfig, "ActiveCfg"); + _projConfigPlatforms.Add(newpcp); + _propSet.AddProperty(newpcp.PropertyKey(), newpcp.PropertyValue()); + + newpcp = new ProjConfigPlatform(pcp, newConfigName, createNewProjectConfig, "Build.0"); + _projConfigPlatforms.Add(newpcp); + _propSet.AddProperty(newpcp.PropertyKey(), newpcp.PropertyValue()); + } + else + { + ProjConfigPlatform newpcp = new ProjConfigPlatform(pcp, newConfigName, createNewProjectConfig); + _projConfigPlatforms.Add(newpcp); + _propSet.AddProperty(newpcp.PropertyKey(), newpcp.PropertyValue()); + } + } + + internal bool LoadConfigurations(List sectionLines) + { + foreach (string line in sectionLines) + { + int p = line.IndexOf('.'); + if (p != -1) + { + int i = line.IndexOf('|', p); + int j = line.IndexOf('.', i); + int l = line.IndexOf('=', j); + int m = line.IndexOf('|', l); + int n = line.Length; + if (i != -1 && j != -1 && l != -1) + { + string slnConfig = line.Substring(p + 1, i - p - 1).Trim(); + string slnPlatform = line.Substring(i + 1, j - i - 1).Trim(); + string build = line.Substring(j + 1, l - j - 1).Trim(); + string deploy = ""; + string projConfig = line.Substring(l + 1, m - l - 1).Trim(); + string projPlatform = line.Substring(m + 1, n - m - 1).Trim(); + + ProjConfigPlatform entry = new ProjConfigPlatform(slnConfig, slnPlatform, build, deploy, projConfig, projPlatform, line); + _projConfigPlatforms.Add(entry); + + if (!_projConfigs.Contains(projConfig)) + _projConfigs.Add(projConfig); + + if (!_projPlatforms.Contains(projPlatform)) + _projPlatforms.Add(projPlatform); + } + } + } + return false; + } + + } + + public partial class SlnPropertySet + { + internal void AddProperty(string key, string value) + { + _values.Add(key, value); + } + } +} diff --git a/src/Cli/dotnet/commands/dotnet-sln/LocalizableStrings.resx b/src/Cli/dotnet/commands/dotnet-sln/LocalizableStrings.resx index 37c35e84400d..42ed673d15a7 100644 --- a/src/Cli/dotnet/commands/dotnet-sln/LocalizableStrings.resx +++ b/src/Cli/dotnet/commands/dotnet-sln/LocalizableStrings.resx @@ -177,4 +177,49 @@ Solution Folder(s) - + + Add new config or platform to a solution file. + + + Solution config {0} already exists. + + + Solution config {0} to copy from, does not exists. + + + Solution platform {0} to copy from, does not exists. + + + Update project options is not specified. + + + Specify at least one config or platform to add. + + + Existing config or platform to copy project settings from. + + + New config to add to the solution. + + + New platform to add to the solution. + + + Indicates whether to update project config or platform settings. + + + Solution platform {0} already exists. + + + Solution file does not exists. + + + The solution file to operate on. If not specified, the command will search the current directory for one. + + + Configuration Manager commands for .NET CLI. + + + Expected file header not found + + \ No newline at end of file diff --git a/src/Cli/dotnet/commands/dotnet-sln/SlnCommandParser.cs b/src/Cli/dotnet/commands/dotnet-sln/SlnCommandParser.cs index 5466d1aa61cd..7362c1da5617 100644 --- a/src/Cli/dotnet/commands/dotnet-sln/SlnCommandParser.cs +++ b/src/Cli/dotnet/commands/dotnet-sln/SlnCommandParser.cs @@ -29,9 +29,11 @@ private static CliCommand ConstructCommand() DocumentedCommand command = new("sln", DocsLink, LocalizableStrings.AppFullName); command.Arguments.Add(SlnArgument); + //command.Subcommands.Add(SlnConfigurationParser.GetCommand()); command.Subcommands.Add(SlnAddParser.GetCommand()); command.Subcommands.Add(SlnListParser.GetCommand()); command.Subcommands.Add(SlnRemoveParser.GetCommand()); + command.Subcommands.Add(SlnConfigurationParser.GetCommand()); command.SetAction((parseResult) => parseResult.HandleMissingCommand()); diff --git a/src/Cli/dotnet/commands/dotnet-sln/configuration/ConfigurationCommandParser.cs b/src/Cli/dotnet/commands/dotnet-sln/configuration/ConfigurationCommandParser.cs new file mode 100644 index 000000000000..d447f8be089d --- /dev/null +++ b/src/Cli/dotnet/commands/dotnet-sln/configuration/ConfigurationCommandParser.cs @@ -0,0 +1,41 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.DotNet.CommandFactory; +using System; +using System.CommandLine; +using System.CommandLine.Invocation; +using System.CommandLine.Parsing; +using System.Resources; +using LocalizableStrings = Microsoft.DotNet.Tools.Sln.LocalizableStrings; + +namespace Microsoft.DotNet.Cli +{ + internal static class SlnConfigurationParser + { + private static readonly CliCommand Command = ConstructCommand(); + + public static CliCommand GetCommand() + { + return Command; + } + + private static CliCommand ConstructCommand() + { + CliCommand command = new("configuration", LocalizableStrings.ConfigurationCommand); + + command.Subcommands.Add(ConfigurationAddParser.GetCommand()); + + /* + command.Subcommands.Add(ConfigureRenameParser.GetCommand()); + command.Subcommands.Add(ConfigureRemoveParser.GetCommand()); + command.Subcommands.Add(ConfigureUpdateParser.GetCommand()); + */ + + command.SetAction((parseResult) => parseResult.HandleMissingCommand()); + + return command; + } + } +} + diff --git a/src/Cli/dotnet/commands/dotnet-sln/configuration/add/AddConfigToSolutionCommand.cs b/src/Cli/dotnet/commands/dotnet-sln/configuration/add/AddConfigToSolutionCommand.cs new file mode 100644 index 000000000000..fcaadc85e958 --- /dev/null +++ b/src/Cli/dotnet/commands/dotnet-sln/configuration/add/AddConfigToSolutionCommand.cs @@ -0,0 +1,78 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.CommandLine.Parsing; +using System.IO; +using System.Linq; +using Microsoft.DotNet.Cli; +using Microsoft.DotNet.Cli.NuGetPackageDownloader; +using Microsoft.DotNet.Cli.Sln.Internal; +using Microsoft.DotNet.Cli.Utils; +using Microsoft.DotNet.Tools.Common; +using LocalizableStrings = Microsoft.DotNet.Tools.Sln.LocalizableStrings; + +namespace Microsoft.DotNet.Cli +{ + internal class AddConfigToSolutionCommand : CommandBase + { + private readonly string _fileOrDirectory; + private readonly string _configName; + private readonly string _platformName; + private readonly string _copyFrom; + private readonly string _updateProj; + + public AddConfigToSolutionCommand( + ParseResult parseResult) : base(parseResult) + { + //_fileOrDirectory = parseResult.GetValue(ConfigurationCommandParser.ConfigureArgument); + _fileOrDirectory = parseResult.GetValue(SlnCommandParser.SlnArgument); + _configName = parseResult.GetValue(ConfigurationAddParser.ConfigName); + _platformName = parseResult.GetValue(ConfigurationAddParser.PlatformName); + _copyFrom = parseResult.GetValue(ConfigurationAddParser.CopyFromConfig); + _updateProj = parseResult.GetValue(ConfigurationAddParser.UpdateProject); + } + + public override int Execute() + { + SlnFile slnFile; + slnFile = SlnFileFactory.CreateFromFileOrDirectory(_fileOrDirectory); + + if (string.IsNullOrEmpty(_configName) && string.IsNullOrEmpty(_platformName)) + { + throw new GracefulException(LocalizableStrings.ConfigurationAddNewConfigPlatformNameMissing); + } + + if (string.IsNullOrEmpty(_updateProj) && string.IsNullOrEmpty(_updateProj)) + { + throw new GracefulException(LocalizableStrings.ConfigurationAddNewConfigOptionUpdateProjMissing); + } + + try + { + if (slnFile.AddNewSlnConfig(_configName, _copyFrom, _updateProj)) + { + slnFile.WriteConfigutations(); + } + } + catch (GracefulException e) + { + switch (e.Message) + { + case "ConfigureAddConfigAlreadyExists": + throw new GracefulException( + string.Format(LocalizableStrings.ConfigurationAddConfigAlreadyExists, _configName)); + + case "ConfigureAddCopyFromDoesNotExists": + throw new GracefulException( + string.Format(LocalizableStrings.ConfigurationAddCopyFromConfigDoesNotExists, _copyFrom)); + } + } + + return 0; + } + } +} + diff --git a/src/Cli/dotnet/commands/dotnet-sln/configuration/add/ConfigurationAddParser.cs b/src/Cli/dotnet/commands/dotnet-sln/configuration/add/ConfigurationAddParser.cs new file mode 100644 index 000000000000..b96e22ee23b1 --- /dev/null +++ b/src/Cli/dotnet/commands/dotnet-sln/configuration/add/ConfigurationAddParser.cs @@ -0,0 +1,58 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using Microsoft.DotNet.Cli; +using System.Collections.Generic; +using System.CommandLine; +using System.CommandLine.Invocation; +using System.CommandLine.Parsing; +//using Microsoft.DotNet.Tools.Sln.Add; +using LocalizableStrings = Microsoft.DotNet.Tools.Sln.LocalizableStrings; + +namespace Microsoft.DotNet.Cli +{ + public static class ConfigurationAddParser + { + public static readonly CliOption ConfigName = new CliOption("-c", "--config") + { + Description = LocalizableStrings.ConfigurationAddOptionNewConfigName + }; + + public static readonly CliOption PlatformName = new CliOption("-p", "--platform") + { + Description = LocalizableStrings.ConfigurationAddOptionNewPlatformName + }; + + public static readonly CliOption UpdateProject = new CliOption("-up", "--updateproj") + { + Description = LocalizableStrings.ConfigurationAddOptionUpdateProjects + }; + + public static readonly CliOption CopyFromConfig = new CliOption("-cf", "--copyfrom") + { + Description = LocalizableStrings.ConfigurationAddOptionCopySettingsFrom + }; + + private static readonly CliCommand Command = ConstructCommand(); + + public static CliCommand GetCommand() + { + return Command; + } + + private static CliCommand ConstructCommand() + { + CliCommand command = new("add", LocalizableStrings.ConfigurationAddCommand); + + command.Options.Add(ConfigName); + command.Options.Add(PlatformName); + command.Options.Add(CopyFromConfig); + command.Options.Add(UpdateProject); + + command.SetAction((parseResult) => new AddConfigToSolutionCommand(parseResult).Execute()); + + return command; + } + } +} diff --git a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.cs.xlf b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.cs.xlf index 089231913f57..2930859ea9f1 100644 --- a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.cs.xlf +++ b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.cs.xlf @@ -27,6 +27,81 @@ Přidá do souboru řešení jeden nebo více projektů. + + Add new config or platform to a solution file. + Add new config or platform to a solution file. + + + + Solution config {0} already exists. + Solution config {0} already exists. + + + + Solution config {0} to copy from, does not exists. + Solution config {0} to copy from, does not exists. + + + + Solution platform {0} to copy from, does not exists. + Solution platform {0} to copy from, does not exists. + + + + Update project options is not specified. + Update project options is not specified. + + + + Specify at least one config or platform to add. + Specify at least one config or platform to add. + + + + Existing config or platform to copy project settings from. + Existing config or platform to copy project settings from. + + + + New config to add to the solution. + New config to add to the solution. + + + + New platform to add to the solution. + New platform to add to the solution. + + + + Indicates whether to update project config or platform settings. + Indicates whether to update project config or platform settings. + + + + Solution platform {0} already exists. + Solution platform {0} already exists. + + + + Solution file does not exists. + Solution file does not exists. + + + + The solution file to operate on. If not specified, the command will search the current directory for one. + The solution file to operate on. If not specified, the command will search the current directory for one. + + + + Configuration Manager commands for .NET CLI. + Configuration Manager commands for .NET CLI. + + + + Expected file header not found + Expected file header not found + + Place project in root of the solution, rather than creating a solution folder. Umístěte projekt do kořene řešení, není potřeba vytvářet složku řešení. diff --git a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.de.xlf b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.de.xlf index b0198ebba4d5..a8e9585caf27 100644 --- a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.de.xlf +++ b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.de.xlf @@ -27,6 +27,81 @@ Fügt einer Projektmappendatei ein oder mehrere Projekte hinzu. + + Add new config or platform to a solution file. + Add new config or platform to a solution file. + + + + Solution config {0} already exists. + Solution config {0} already exists. + + + + Solution config {0} to copy from, does not exists. + Solution config {0} to copy from, does not exists. + + + + Solution platform {0} to copy from, does not exists. + Solution platform {0} to copy from, does not exists. + + + + Update project options is not specified. + Update project options is not specified. + + + + Specify at least one config or platform to add. + Specify at least one config or platform to add. + + + + Existing config or platform to copy project settings from. + Existing config or platform to copy project settings from. + + + + New config to add to the solution. + New config to add to the solution. + + + + New platform to add to the solution. + New platform to add to the solution. + + + + Indicates whether to update project config or platform settings. + Indicates whether to update project config or platform settings. + + + + Solution platform {0} already exists. + Solution platform {0} already exists. + + + + Solution file does not exists. + Solution file does not exists. + + + + The solution file to operate on. If not specified, the command will search the current directory for one. + The solution file to operate on. If not specified, the command will search the current directory for one. + + + + Configuration Manager commands for .NET CLI. + Configuration Manager commands for .NET CLI. + + + + Expected file header not found + Expected file header not found + + Place project in root of the solution, rather than creating a solution folder. Platzieren Sie das Projekt im Stamm der Projektmappe, statt einen Projektmappenordner zu erstellen. diff --git a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.es.xlf b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.es.xlf index 2c3528e4e5e9..7ec986bf3067 100644 --- a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.es.xlf +++ b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.es.xlf @@ -27,6 +27,81 @@ Agrega uno o varios proyectos a un archivo de solución. + + Add new config or platform to a solution file. + Add new config or platform to a solution file. + + + + Solution config {0} already exists. + Solution config {0} already exists. + + + + Solution config {0} to copy from, does not exists. + Solution config {0} to copy from, does not exists. + + + + Solution platform {0} to copy from, does not exists. + Solution platform {0} to copy from, does not exists. + + + + Update project options is not specified. + Update project options is not specified. + + + + Specify at least one config or platform to add. + Specify at least one config or platform to add. + + + + Existing config or platform to copy project settings from. + Existing config or platform to copy project settings from. + + + + New config to add to the solution. + New config to add to the solution. + + + + New platform to add to the solution. + New platform to add to the solution. + + + + Indicates whether to update project config or platform settings. + Indicates whether to update project config or platform settings. + + + + Solution platform {0} already exists. + Solution platform {0} already exists. + + + + Solution file does not exists. + Solution file does not exists. + + + + The solution file to operate on. If not specified, the command will search the current directory for one. + The solution file to operate on. If not specified, the command will search the current directory for one. + + + + Configuration Manager commands for .NET CLI. + Configuration Manager commands for .NET CLI. + + + + Expected file header not found + Expected file header not found + + Place project in root of the solution, rather than creating a solution folder. Coloque el proyecto en la raíz de la solución, en lugar de crear una carpeta de soluciones. diff --git a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.fr.xlf b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.fr.xlf index 36edf9f53333..a03977866b7c 100644 --- a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.fr.xlf +++ b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.fr.xlf @@ -27,6 +27,81 @@ Ajoutez un ou plusieurs projets à un fichier solution. + + Add new config or platform to a solution file. + Add new config or platform to a solution file. + + + + Solution config {0} already exists. + Solution config {0} already exists. + + + + Solution config {0} to copy from, does not exists. + Solution config {0} to copy from, does not exists. + + + + Solution platform {0} to copy from, does not exists. + Solution platform {0} to copy from, does not exists. + + + + Update project options is not specified. + Update project options is not specified. + + + + Specify at least one config or platform to add. + Specify at least one config or platform to add. + + + + Existing config or platform to copy project settings from. + Existing config or platform to copy project settings from. + + + + New config to add to the solution. + New config to add to the solution. + + + + New platform to add to the solution. + New platform to add to the solution. + + + + Indicates whether to update project config or platform settings. + Indicates whether to update project config or platform settings. + + + + Solution platform {0} already exists. + Solution platform {0} already exists. + + + + Solution file does not exists. + Solution file does not exists. + + + + The solution file to operate on. If not specified, the command will search the current directory for one. + The solution file to operate on. If not specified, the command will search the current directory for one. + + + + Configuration Manager commands for .NET CLI. + Configuration Manager commands for .NET CLI. + + + + Expected file header not found + Expected file header not found + + Place project in root of the solution, rather than creating a solution folder. Place le projet à la racine de la solution, au lieu de créer un dossier solution. diff --git a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.it.xlf b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.it.xlf index fecda2432e9e..ec234987f9f8 100644 --- a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.it.xlf +++ b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.it.xlf @@ -27,6 +27,81 @@ Consente di aggiungere uno o più progetti a un file di soluzione. + + Add new config or platform to a solution file. + Add new config or platform to a solution file. + + + + Solution config {0} already exists. + Solution config {0} already exists. + + + + Solution config {0} to copy from, does not exists. + Solution config {0} to copy from, does not exists. + + + + Solution platform {0} to copy from, does not exists. + Solution platform {0} to copy from, does not exists. + + + + Update project options is not specified. + Update project options is not specified. + + + + Specify at least one config or platform to add. + Specify at least one config or platform to add. + + + + Existing config or platform to copy project settings from. + Existing config or platform to copy project settings from. + + + + New config to add to the solution. + New config to add to the solution. + + + + New platform to add to the solution. + New platform to add to the solution. + + + + Indicates whether to update project config or platform settings. + Indicates whether to update project config or platform settings. + + + + Solution platform {0} already exists. + Solution platform {0} already exists. + + + + Solution file does not exists. + Solution file does not exists. + + + + The solution file to operate on. If not specified, the command will search the current directory for one. + The solution file to operate on. If not specified, the command will search the current directory for one. + + + + Configuration Manager commands for .NET CLI. + Configuration Manager commands for .NET CLI. + + + + Expected file header not found + Expected file header not found + + Place project in root of the solution, rather than creating a solution folder. Inserisce il progetto nella radice della soluzione invece di creare una cartella soluzione. diff --git a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.ja.xlf b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.ja.xlf index 122aee73495b..b320470ae621 100644 --- a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.ja.xlf +++ b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.ja.xlf @@ -27,6 +27,81 @@ 1 つ以上のプロジェクトをソリューション ファイルに追加します。 + + Add new config or platform to a solution file. + Add new config or platform to a solution file. + + + + Solution config {0} already exists. + Solution config {0} already exists. + + + + Solution config {0} to copy from, does not exists. + Solution config {0} to copy from, does not exists. + + + + Solution platform {0} to copy from, does not exists. + Solution platform {0} to copy from, does not exists. + + + + Update project options is not specified. + Update project options is not specified. + + + + Specify at least one config or platform to add. + Specify at least one config or platform to add. + + + + Existing config or platform to copy project settings from. + Existing config or platform to copy project settings from. + + + + New config to add to the solution. + New config to add to the solution. + + + + New platform to add to the solution. + New platform to add to the solution. + + + + Indicates whether to update project config or platform settings. + Indicates whether to update project config or platform settings. + + + + Solution platform {0} already exists. + Solution platform {0} already exists. + + + + Solution file does not exists. + Solution file does not exists. + + + + The solution file to operate on. If not specified, the command will search the current directory for one. + The solution file to operate on. If not specified, the command will search the current directory for one. + + + + Configuration Manager commands for .NET CLI. + Configuration Manager commands for .NET CLI. + + + + Expected file header not found + Expected file header not found + + Place project in root of the solution, rather than creating a solution folder. ソリューション フォルダーを作成するのではなく、プロジェクトをソリューションのルートに配置します。 diff --git a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.ko.xlf b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.ko.xlf index 63f51c9ae3ab..d60460085cb5 100644 --- a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.ko.xlf +++ b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.ko.xlf @@ -27,6 +27,81 @@ 솔루션 파일에 하나 이상의 프로젝트를 추가합니다. + + Add new config or platform to a solution file. + Add new config or platform to a solution file. + + + + Solution config {0} already exists. + Solution config {0} already exists. + + + + Solution config {0} to copy from, does not exists. + Solution config {0} to copy from, does not exists. + + + + Solution platform {0} to copy from, does not exists. + Solution platform {0} to copy from, does not exists. + + + + Update project options is not specified. + Update project options is not specified. + + + + Specify at least one config or platform to add. + Specify at least one config or platform to add. + + + + Existing config or platform to copy project settings from. + Existing config or platform to copy project settings from. + + + + New config to add to the solution. + New config to add to the solution. + + + + New platform to add to the solution. + New platform to add to the solution. + + + + Indicates whether to update project config or platform settings. + Indicates whether to update project config or platform settings. + + + + Solution platform {0} already exists. + Solution platform {0} already exists. + + + + Solution file does not exists. + Solution file does not exists. + + + + The solution file to operate on. If not specified, the command will search the current directory for one. + The solution file to operate on. If not specified, the command will search the current directory for one. + + + + Configuration Manager commands for .NET CLI. + Configuration Manager commands for .NET CLI. + + + + Expected file header not found + Expected file header not found + + Place project in root of the solution, rather than creating a solution folder. 솔루션 폴더를 만드는 대신, 솔루션의 루트에 프로젝트를 배치하세요. diff --git a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.pl.xlf b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.pl.xlf index ad8468092d26..876e4001fa8e 100644 --- a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.pl.xlf +++ b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.pl.xlf @@ -27,6 +27,81 @@ Dodaj co najmniej jeden projekt do pliku rozwiązania. + + Add new config or platform to a solution file. + Add new config or platform to a solution file. + + + + Solution config {0} already exists. + Solution config {0} already exists. + + + + Solution config {0} to copy from, does not exists. + Solution config {0} to copy from, does not exists. + + + + Solution platform {0} to copy from, does not exists. + Solution platform {0} to copy from, does not exists. + + + + Update project options is not specified. + Update project options is not specified. + + + + Specify at least one config or platform to add. + Specify at least one config or platform to add. + + + + Existing config or platform to copy project settings from. + Existing config or platform to copy project settings from. + + + + New config to add to the solution. + New config to add to the solution. + + + + New platform to add to the solution. + New platform to add to the solution. + + + + Indicates whether to update project config or platform settings. + Indicates whether to update project config or platform settings. + + + + Solution platform {0} already exists. + Solution platform {0} already exists. + + + + Solution file does not exists. + Solution file does not exists. + + + + The solution file to operate on. If not specified, the command will search the current directory for one. + The solution file to operate on. If not specified, the command will search the current directory for one. + + + + Configuration Manager commands for .NET CLI. + Configuration Manager commands for .NET CLI. + + + + Expected file header not found + Expected file header not found + + Place project in root of the solution, rather than creating a solution folder. Umieść projekt w katalogu głównym rozwiązania zamiast tworzyć folder rozwiązania. diff --git a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.pt-BR.xlf b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.pt-BR.xlf index 53769e4548ff..774fcc214097 100644 --- a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.pt-BR.xlf +++ b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.pt-BR.xlf @@ -27,6 +27,81 @@ Adicionar um ou mais projetos em um arquivo de solução. + + Add new config or platform to a solution file. + Add new config or platform to a solution file. + + + + Solution config {0} already exists. + Solution config {0} already exists. + + + + Solution config {0} to copy from, does not exists. + Solution config {0} to copy from, does not exists. + + + + Solution platform {0} to copy from, does not exists. + Solution platform {0} to copy from, does not exists. + + + + Update project options is not specified. + Update project options is not specified. + + + + Specify at least one config or platform to add. + Specify at least one config or platform to add. + + + + Existing config or platform to copy project settings from. + Existing config or platform to copy project settings from. + + + + New config to add to the solution. + New config to add to the solution. + + + + New platform to add to the solution. + New platform to add to the solution. + + + + Indicates whether to update project config or platform settings. + Indicates whether to update project config or platform settings. + + + + Solution platform {0} already exists. + Solution platform {0} already exists. + + + + Solution file does not exists. + Solution file does not exists. + + + + The solution file to operate on. If not specified, the command will search the current directory for one. + The solution file to operate on. If not specified, the command will search the current directory for one. + + + + Configuration Manager commands for .NET CLI. + Configuration Manager commands for .NET CLI. + + + + Expected file header not found + Expected file header not found + + Place project in root of the solution, rather than creating a solution folder. Coloque o projeto na raiz da solução, em vez de criar uma pasta da solução. diff --git a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.ru.xlf b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.ru.xlf index e42eaa24f24e..1923d18029ab 100644 --- a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.ru.xlf +++ b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.ru.xlf @@ -27,6 +27,81 @@ Добавление проектов в файл решения. + + Add new config or platform to a solution file. + Add new config or platform to a solution file. + + + + Solution config {0} already exists. + Solution config {0} already exists. + + + + Solution config {0} to copy from, does not exists. + Solution config {0} to copy from, does not exists. + + + + Solution platform {0} to copy from, does not exists. + Solution platform {0} to copy from, does not exists. + + + + Update project options is not specified. + Update project options is not specified. + + + + Specify at least one config or platform to add. + Specify at least one config or platform to add. + + + + Existing config or platform to copy project settings from. + Existing config or platform to copy project settings from. + + + + New config to add to the solution. + New config to add to the solution. + + + + New platform to add to the solution. + New platform to add to the solution. + + + + Indicates whether to update project config or platform settings. + Indicates whether to update project config or platform settings. + + + + Solution platform {0} already exists. + Solution platform {0} already exists. + + + + Solution file does not exists. + Solution file does not exists. + + + + The solution file to operate on. If not specified, the command will search the current directory for one. + The solution file to operate on. If not specified, the command will search the current directory for one. + + + + Configuration Manager commands for .NET CLI. + Configuration Manager commands for .NET CLI. + + + + Expected file header not found + Expected file header not found + + Place project in root of the solution, rather than creating a solution folder. Поместите проект в корень решения вместо создания папки решения. diff --git a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.tr.xlf b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.tr.xlf index 3fc9ca0d6642..1db56fdc8e6f 100644 --- a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.tr.xlf +++ b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.tr.xlf @@ -27,6 +27,81 @@ Bir çözüm dosyasına bir veya daha fazla proje ekler. + + Add new config or platform to a solution file. + Add new config or platform to a solution file. + + + + Solution config {0} already exists. + Solution config {0} already exists. + + + + Solution config {0} to copy from, does not exists. + Solution config {0} to copy from, does not exists. + + + + Solution platform {0} to copy from, does not exists. + Solution platform {0} to copy from, does not exists. + + + + Update project options is not specified. + Update project options is not specified. + + + + Specify at least one config or platform to add. + Specify at least one config or platform to add. + + + + Existing config or platform to copy project settings from. + Existing config or platform to copy project settings from. + + + + New config to add to the solution. + New config to add to the solution. + + + + New platform to add to the solution. + New platform to add to the solution. + + + + Indicates whether to update project config or platform settings. + Indicates whether to update project config or platform settings. + + + + Solution platform {0} already exists. + Solution platform {0} already exists. + + + + Solution file does not exists. + Solution file does not exists. + + + + The solution file to operate on. If not specified, the command will search the current directory for one. + The solution file to operate on. If not specified, the command will search the current directory for one. + + + + Configuration Manager commands for .NET CLI. + Configuration Manager commands for .NET CLI. + + + + Expected file header not found + Expected file header not found + + Place project in root of the solution, rather than creating a solution folder. Bir çözüm klasörü oluşturmak yerine projeyi çözümün köküne yerleştirin. diff --git a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.zh-Hans.xlf b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.zh-Hans.xlf index 2a3a6c0541ef..f88a305422c2 100644 --- a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.zh-Hans.xlf +++ b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.zh-Hans.xlf @@ -27,6 +27,81 @@ 将一个或多个项目添加到解决方案文件。 + + Add new config or platform to a solution file. + Add new config or platform to a solution file. + + + + Solution config {0} already exists. + Solution config {0} already exists. + + + + Solution config {0} to copy from, does not exists. + Solution config {0} to copy from, does not exists. + + + + Solution platform {0} to copy from, does not exists. + Solution platform {0} to copy from, does not exists. + + + + Update project options is not specified. + Update project options is not specified. + + + + Specify at least one config or platform to add. + Specify at least one config or platform to add. + + + + Existing config or platform to copy project settings from. + Existing config or platform to copy project settings from. + + + + New config to add to the solution. + New config to add to the solution. + + + + New platform to add to the solution. + New platform to add to the solution. + + + + Indicates whether to update project config or platform settings. + Indicates whether to update project config or platform settings. + + + + Solution platform {0} already exists. + Solution platform {0} already exists. + + + + Solution file does not exists. + Solution file does not exists. + + + + The solution file to operate on. If not specified, the command will search the current directory for one. + The solution file to operate on. If not specified, the command will search the current directory for one. + + + + Configuration Manager commands for .NET CLI. + Configuration Manager commands for .NET CLI. + + + + Expected file header not found + Expected file header not found + + Place project in root of the solution, rather than creating a solution folder. 将项目放在解决方案的根目录下,而不是创建解决方案文件夹。 diff --git a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.zh-Hant.xlf b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.zh-Hant.xlf index 226afb361f77..f1ebb4931db0 100644 --- a/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.zh-Hant.xlf +++ b/src/Cli/dotnet/commands/dotnet-sln/xlf/LocalizableStrings.zh-Hant.xlf @@ -27,6 +27,81 @@ 為解決方案檔新增一或多個專案。 + + Add new config or platform to a solution file. + Add new config or platform to a solution file. + + + + Solution config {0} already exists. + Solution config {0} already exists. + + + + Solution config {0} to copy from, does not exists. + Solution config {0} to copy from, does not exists. + + + + Solution platform {0} to copy from, does not exists. + Solution platform {0} to copy from, does not exists. + + + + Update project options is not specified. + Update project options is not specified. + + + + Specify at least one config or platform to add. + Specify at least one config or platform to add. + + + + Existing config or platform to copy project settings from. + Existing config or platform to copy project settings from. + + + + New config to add to the solution. + New config to add to the solution. + + + + New platform to add to the solution. + New platform to add to the solution. + + + + Indicates whether to update project config or platform settings. + Indicates whether to update project config or platform settings. + + + + Solution platform {0} already exists. + Solution platform {0} already exists. + + + + Solution file does not exists. + Solution file does not exists. + + + + The solution file to operate on. If not specified, the command will search the current directory for one. + The solution file to operate on. If not specified, the command will search the current directory for one. + + + + Configuration Manager commands for .NET CLI. + Configuration Manager commands for .NET CLI. + + + + Expected file header not found + Expected file header not found + + Place project in root of the solution, rather than creating a solution folder. 請將專案放置在解決方案的根目錄中,而非放置於建立解決方案的資料夾中。 diff --git a/src/Tests/dotnet-sln.Tests/GivenDotnetSlnConfigurationAdd.cs b/src/Tests/dotnet-sln.Tests/GivenDotnetSlnConfigurationAdd.cs new file mode 100644 index 000000000000..08fca7402dfd --- /dev/null +++ b/src/Tests/dotnet-sln.Tests/GivenDotnetSlnConfigurationAdd.cs @@ -0,0 +1,546 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.DotNet.Cli.Sln.Internal; +using Microsoft.DotNet.Cli.Utils; +using Microsoft.DotNet.Tools; +using Microsoft.DotNet.Tools.Common; +using LocalizableStrings = Microsoft.DotNet.Tools.Sln.LocalizableStrings; + +namespace Microsoft.DotNet.Cli.Sln.Add.Tests +{ + public class GivenDotnetSlnConfigurationAdd : SdkTest + { + private Func HelpText = (defaultVal) => $@"Description: + Add new config or platform to a solution file. + +Usage: + dotnet sln configuration add [options] + +Arguments: + The solution file to operate on. If not specified, the command will search the current directory for one. [default: {PathUtility.EnsureTrailingSlash(defaultVal)}] + +Options: + -c, --config New config to add to the solution. + -p, --platform

New platform to add to the solution. + -cf, --copyfrom Existing config or platform to copy project settings from. + -up, --updateproj Indicates whether to update project config or platform settings. + -?, -h, --help Show command line help."; + + public GivenDotnetSlnConfigurationAdd(ITestOutputHelper log) : base(log) + { + } + + private const string ExpectedSlnWhenNewConfigIsAddedSingleProjCopyfromUpdateProjSlnIsUpdated_n = @" +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26006.2 +MinimumVisualStudioVersion = 10.0.40219.1 +Project(""{9A19103F-16F7-4668-BE54-9A1E7A4F7556}"") = ""App"", ""App\App.csproj"", ""{7072A694-548F-4CAE-A58F-12D257D5F486}"" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + newconfig|Any CPU = newconfig|Any CPU + newconfig|x64 = newconfig|x64 + newconfig|x86 = newconfig|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x64.ActiveCfg = Debug|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x64.Build.0 = Debug|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x86.ActiveCfg = Debug|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x86.Build.0 = Debug|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|Any CPU.Build.0 = Release|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x64.ActiveCfg = Release|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x64.Build.0 = Release|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.ActiveCfg = Release|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.Build.0 = Release|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.newconfig|Any CPU.ActiveCfg = Debug|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.newconfig|Any CPU.Build.0 = Debug|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.newconfig|x64.ActiveCfg = Debug|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.newconfig|x64.Build.0 = Debug|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.newconfig|x86.ActiveCfg = Debug|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.newconfig|x86.Build.0 = Debug|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal +"; + + private const string ExpectedSlnWhenNewConfigIsAddedSingleProjCopyfromUpdateProjSlnIsUpdated_y = @" +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26006.2 +MinimumVisualStudioVersion = 10.0.40219.1 +Project(""{9A19103F-16F7-4668-BE54-9A1E7A4F7556}"") = ""App"", ""App\App.csproj"", ""{7072A694-548F-4CAE-A58F-12D257D5F486}"" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + newconfig|Any CPU = newconfig|Any CPU + newconfig|x64 = newconfig|x64 + newconfig|x86 = newconfig|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x64.ActiveCfg = Debug|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x64.Build.0 = Debug|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x86.ActiveCfg = Debug|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x86.Build.0 = Debug|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|Any CPU.Build.0 = Release|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x64.ActiveCfg = Release|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x64.Build.0 = Release|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.ActiveCfg = Release|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.Build.0 = Release|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.newconfig|Any CPU.ActiveCfg = newconfig|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.newconfig|Any CPU.Build.0 = newconfig|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.newconfig|x64.ActiveCfg = newconfig|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.newconfig|x64.Build.0 = newconfig|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.newconfig|x86.ActiveCfg = newconfig|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.newconfig|x86.Build.0 = newconfig|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal +"; + + private const string ExpectedSlnWhenNewConfigIsAddedMultipleProjCopyfromUpdateProjSlnIsUpdated_n = @" +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32929.385 +MinimumVisualStudioVersion = 10.0.40219.1 +Project(""{9A19103F-16F7-4668-BE54-9A1E7A4F7556}"") = ""App"", ""App\App.csproj"", ""{7072A694-548F-4CAE-A58F-12D257D5F486}"" +EndProject +Project(""{9A19103F-16F7-4668-BE54-9A1E7A4F7556}"") = ""Lib"", ""Lib\Lib.csproj"", ""{D4ED07FD-E893-4D38-8E19-33C3027D687A}"" +EndProject +Project(""{9A19103F-16F7-4668-BE54-9A1E7A4F7556}"") = ""First"", ""Multiple\First.csproj"", ""{F1383793-E608-49EA-A9BE-B7C26E94850B}"" +EndProject +Project(""{9A19103F-16F7-4668-BE54-9A1E7A4F7556}"") = ""Second"", ""Multiple\Second.csproj"", ""{5F64398F-08F6-4FDA-87DE-6F138AF81DC8}"" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + newconfig|Any CPU = newconfig|Any CPU + newconfig|x64 = newconfig|x64 + newconfig|x86 = newconfig|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x64.ActiveCfg = Debug|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x86.ActiveCfg = Debug|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|Any CPU.Build.0 = Release|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x64.ActiveCfg = Release|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x64.Build.0 = Release|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.ActiveCfg = Release|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.Build.0 = Release|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.newconfig|Any CPU.ActiveCfg = Debug|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.newconfig|x64.ActiveCfg = Debug|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.newconfig|x86.ActiveCfg = Debug|x86 + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Debug|x64.ActiveCfg = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Debug|x64.Build.0 = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Debug|x86.ActiveCfg = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Debug|x86.Build.0 = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Release|Any CPU.Build.0 = Release|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Release|x64.ActiveCfg = Release|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Release|x64.Build.0 = Release|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Release|x86.ActiveCfg = Release|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Release|x86.Build.0 = Release|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.newconfig|Any CPU.ActiveCfg = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.newconfig|Any CPU.Build.0 = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.newconfig|x64.ActiveCfg = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.newconfig|x64.Build.0 = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.newconfig|x86.ActiveCfg = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.newconfig|x86.Build.0 = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Debug|x64.ActiveCfg = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Debug|x64.Build.0 = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Debug|x86.ActiveCfg = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Debug|x86.Build.0 = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Release|Any CPU.Build.0 = Release|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Release|x64.ActiveCfg = Release|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Release|x64.Build.0 = Release|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Release|x86.ActiveCfg = Release|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Release|x86.Build.0 = Release|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.newconfig|Any CPU.ActiveCfg = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.newconfig|Any CPU.Build.0 = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.newconfig|x64.ActiveCfg = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.newconfig|x64.Build.0 = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.newconfig|x86.ActiveCfg = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.newconfig|x86.Build.0 = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Debug|x64.ActiveCfg = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Debug|x64.Build.0 = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Debug|x86.ActiveCfg = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Debug|x86.Build.0 = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Release|Any CPU.Build.0 = Release|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Release|x64.ActiveCfg = Release|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Release|x64.Build.0 = Release|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Release|x86.ActiveCfg = Release|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Release|x86.Build.0 = Release|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.newconfig|Any CPU.ActiveCfg = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.newconfig|Any CPU.Build.0 = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.newconfig|x64.ActiveCfg = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.newconfig|x64.Build.0 = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.newconfig|x86.ActiveCfg = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.newconfig|x86.Build.0 = Debug|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {69061246-1432-4C95-A7C9-B17C637C8639} + EndGlobalSection +EndGlobal +"; + + private const string ExpectedSlnWhenNewConfigIsAddedMultipleProjCopyfromUpdateProjSlnIsUpdated_y = @" +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32929.385 +MinimumVisualStudioVersion = 10.0.40219.1 +Project(""{9A19103F-16F7-4668-BE54-9A1E7A4F7556}"") = ""App"", ""App\App.csproj"", ""{7072A694-548F-4CAE-A58F-12D257D5F486}"" +EndProject +Project(""{9A19103F-16F7-4668-BE54-9A1E7A4F7556}"") = ""Lib"", ""Lib\Lib.csproj"", ""{D4ED07FD-E893-4D38-8E19-33C3027D687A}"" +EndProject +Project(""{9A19103F-16F7-4668-BE54-9A1E7A4F7556}"") = ""First"", ""Multiple\First.csproj"", ""{F1383793-E608-49EA-A9BE-B7C26E94850B}"" +EndProject +Project(""{9A19103F-16F7-4668-BE54-9A1E7A4F7556}"") = ""Second"", ""Multiple\Second.csproj"", ""{5F64398F-08F6-4FDA-87DE-6F138AF81DC8}"" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + newconfig|Any CPU = newconfig|Any CPU + newconfig|x64 = newconfig|x64 + newconfig|x86 = newconfig|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x64.ActiveCfg = Debug|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x86.ActiveCfg = Debug|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|Any CPU.Build.0 = Release|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x64.ActiveCfg = Release|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x64.Build.0 = Release|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.ActiveCfg = Release|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.Build.0 = Release|x86 + {7072A694-548F-4CAE-A58F-12D257D5F486}.newconfig|Any CPU.ActiveCfg = newconfig|Any CPU + {7072A694-548F-4CAE-A58F-12D257D5F486}.newconfig|x64.ActiveCfg = newconfig|x64 + {7072A694-548F-4CAE-A58F-12D257D5F486}.newconfig|x86.ActiveCfg = newconfig|x86 + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Debug|x64.ActiveCfg = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Debug|x64.Build.0 = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Debug|x86.ActiveCfg = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Debug|x86.Build.0 = Debug|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Release|Any CPU.Build.0 = Release|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Release|x64.ActiveCfg = Release|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Release|x64.Build.0 = Release|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Release|x86.ActiveCfg = Release|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.Release|x86.Build.0 = Release|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.newconfig|Any CPU.ActiveCfg = newconfig|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.newconfig|Any CPU.Build.0 = newconfig|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.newconfig|x64.ActiveCfg = newconfig|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.newconfig|x64.Build.0 = newconfig|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.newconfig|x86.ActiveCfg = newconfig|Any CPU + {D4ED07FD-E893-4D38-8E19-33C3027D687A}.newconfig|x86.Build.0 = newconfig|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Debug|x64.ActiveCfg = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Debug|x64.Build.0 = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Debug|x86.ActiveCfg = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Debug|x86.Build.0 = Debug|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Release|Any CPU.Build.0 = Release|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Release|x64.ActiveCfg = Release|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Release|x64.Build.0 = Release|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Release|x86.ActiveCfg = Release|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.Release|x86.Build.0 = Release|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.newconfig|Any CPU.ActiveCfg = newconfig|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.newconfig|Any CPU.Build.0 = newconfig|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.newconfig|x64.ActiveCfg = newconfig|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.newconfig|x64.Build.0 = newconfig|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.newconfig|x86.ActiveCfg = newconfig|Any CPU + {F1383793-E608-49EA-A9BE-B7C26E94850B}.newconfig|x86.Build.0 = newconfig|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Debug|x64.ActiveCfg = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Debug|x64.Build.0 = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Debug|x86.ActiveCfg = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Debug|x86.Build.0 = Debug|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Release|Any CPU.Build.0 = Release|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Release|x64.ActiveCfg = Release|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Release|x64.Build.0 = Release|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Release|x86.ActiveCfg = Release|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.Release|x86.Build.0 = Release|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.newconfig|Any CPU.ActiveCfg = newconfig|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.newconfig|Any CPU.Build.0 = newconfig|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.newconfig|x64.ActiveCfg = newconfig|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.newconfig|x64.Build.0 = newconfig|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.newconfig|x86.ActiveCfg = newconfig|Any CPU + {5F64398F-08F6-4FDA-87DE-6F138AF81DC8}.newconfig|x86.Build.0 = newconfig|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {69061246-1432-4C95-A7C9-B17C637C8639} + EndGlobalSection +EndGlobal +"; + + private const string ExpectedSlnWhenNewConfigIsAddedSlnFileWithNoProjectReferencesSlnIsUpdated = @" +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26006.2 +MinimumVisualStudioVersion = 10.0.40219.1 +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + newconfig|Any CPU = newconfig|Any CPU + newconfig|x64 = newconfig|x64 + newconfig|x86 = newconfig|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal +"; + + [Theory] + [InlineData("--help")] + [InlineData("-h")] + [InlineData("-?")] + [InlineData("/?")] + public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg) + { + var cmd = new DotnetCommand(Log) + .Execute($"sln", "configuration", "add", helpArg); + cmd.Should().Pass(); + cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText(Directory.GetCurrentDirectory())); + } + + [Theory] + [InlineData("")] + public void WhenNoCommandIsPassedItPrintsError(string commandName) + { + var cmd = new DotnetCommand(Log) + .Execute($"sln configuration {commandName}".Trim().Split()); + cmd.Should().Fail(); + cmd.StdErr.Should().Be(CommonLocalizableStrings.RequiredCommandNotPassed); + } + + [Theory] + [InlineData("unknownCommandName")] + public void WhenUnknownCommandIsPassedItPrintsError(string commandName) + { + var cmd = new DotnetCommand(Log) + .Execute($"sln configuration {commandName}".Trim().Split()); + cmd.Should().Fail(); + cmd.StdErr.Should().Be("Unrecognized command or argument 'unknownCommandName'."); + } + + [Fact] + public void WhenNoConfigIsPassedItPrintsErrorAndUsage() + { + var projectDirectory = _testAssetsManager + .CopyTestAsset("TestAppWithSlnAndReferenceToSingleCsproj", identifier: "GivenDotnetSlnConfigurationAdd") + .WithSource() + .Path; + + var cmd = new DotnetCommand(Log) + .WithWorkingDirectory(projectDirectory) + .Execute(@"sln", "App.sln", "configuration", "add"); + cmd.Should().Fail(); + cmd.StdErr.Should().Be(LocalizableStrings.ConfigurationAddNewConfigPlatformNameMissing); + cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(""); + } + + [Fact] + public void WhenNoUnpdateProjIsPassedItPrintsErrorAndUsage() + { + var projectDirectory = _testAssetsManager + .CopyTestAsset("TestAppWithSlnAndReferenceToSingleCsproj", identifier: "GivenDotnetSlnConfigurationAdd") + .WithSource() + .Path; + + var cmd = new DotnetCommand(Log) + .WithWorkingDirectory(projectDirectory) + .Execute(@"sln", "App.sln", "configuration", "add", "-c", "newconfig"); + cmd.Should().Fail(); + cmd.StdErr.Should().Be(LocalizableStrings.ConfigurationAddNewConfigOptionUpdateProjMissing); + cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(""); + } + + [Fact] + public void WhenNewConfigIsAddedSingleProjCopyfromUpdateProjSlnIsUpdated_n() + { + var projectDirectory = _testAssetsManager + .CopyTestAsset("TestAppWithSlnAndReferenceToSingleCsproj") + .WithSource() + .Path; + + var cmd = new DotnetCommand(Log) + .WithWorkingDirectory(projectDirectory) + .Execute($"sln", "App.sln", "configuration", "add", "-c", "newconfig", "-cf", "Debug", "-up", "n"); + cmd.Should().Pass(); + + var slnPath = Path.Combine(projectDirectory, "App.sln"); + File.ReadAllText(slnPath) + .Should().BeVisuallyEquivalentTo(ExpectedSlnWhenNewConfigIsAddedSingleProjCopyfromUpdateProjSlnIsUpdated_n); + } + + [Fact] + public void WhenNewConfigIsAddedSingleProjCopyfromUpdateProjSlnIsUpdated_y() + { + var projectDirectory = _testAssetsManager + .CopyTestAsset("TestAppWithSlnAndReferenceToSingleCsproj") + .WithSource() + .Path; + + var cmd = new DotnetCommand(Log) + .WithWorkingDirectory(projectDirectory) + .Execute($"sln", "App.sln", "configuration", "add", "-c", "newconfig", "-cf", "Debug", "-up", "y"); + cmd.Should().Pass(); + + var slnPath = Path.Combine(projectDirectory, "App.sln"); + File.ReadAllText(slnPath) + .Should().BeVisuallyEquivalentTo(ExpectedSlnWhenNewConfigIsAddedSingleProjCopyfromUpdateProjSlnIsUpdated_y); + + } + + [Fact] + public void WhenNewConfigIsAddedMultipleProjCopyfromUpdateProjSlnIsUpdated_n() + { + var projectDirectory = _testAssetsManager + .CopyTestAsset("TestAppWithSlnAndReferencesToMultipleCsproj") + .WithSource() + .Path; + + var cmd = new DotnetCommand(Log) + .WithWorkingDirectory(projectDirectory) + .Execute($"sln", "App.sln", "configuration", "add", "-c", "newconfig", "-cf", "Debug", "-up", "n"); + cmd.Should().Pass(); + + var slnPath = Path.Combine(projectDirectory, "App.sln"); + File.ReadAllText(slnPath) + .Should().BeVisuallyEquivalentTo(ExpectedSlnWhenNewConfigIsAddedMultipleProjCopyfromUpdateProjSlnIsUpdated_n); + } + + [Fact] + public void WhenNewConfigIsAddedMultipleProjCopyfromUpdateProjSlnIsUpdated_y() + { + var projectDirectory = _testAssetsManager + .CopyTestAsset("TestAppWithSlnAndReferencesToMultipleCsproj") + .WithSource() + .Path; + + var cmd = new DotnetCommand(Log) + .WithWorkingDirectory(projectDirectory) + .Execute($"sln", "App.sln", "configuration", "add", "-c", "newconfig", "-cf", "Debug", "-up", "y"); + cmd.Should().Pass(); + + var slnPath = Path.Combine(projectDirectory, "App.sln"); + File.ReadAllText(slnPath) + .Should().BeVisuallyEquivalentTo(ExpectedSlnWhenNewConfigIsAddedMultipleProjCopyfromUpdateProjSlnIsUpdated_y); + + } + + [Fact] + public void WhenNewConfigIsAddedSlnFileWithNoProjectReferencesSlnIsUpdated() + { + var projectDirectory = _testAssetsManager + .CopyTestAsset("SlnFileWithNoProjectReferencesAndCSharpProject") + .WithSource() + .Path; + + var cmd = new DotnetCommand(Log) + .WithWorkingDirectory(projectDirectory) + .Execute($"sln", "App.sln", "configuration", "add", "-c", "newconfig", "-cf", "Debug", "-up", "y"); + cmd.Should().Pass(); + + var slnPath = Path.Combine(projectDirectory, "App.sln"); + File.ReadAllText(slnPath) + .Should().BeVisuallyEquivalentTo(ExpectedSlnWhenNewConfigIsAddedSlnFileWithNoProjectReferencesSlnIsUpdated); + } + + private string GetExpectedSlnContents( + string slnPath, + string slnTemplate, + string expectedLibProjectGuid = null) + { + var slnFile = SlnFile.Read(slnPath); + + if (string.IsNullOrEmpty(expectedLibProjectGuid)) + { + var matchingProjects = slnFile.Projects + .Where((p) => p.FilePath.EndsWith("Lib.csproj")) + .ToList(); + + matchingProjects.Count.Should().Be(1); + var slnProject = matchingProjects[0]; + expectedLibProjectGuid = slnProject.Id; + } + var slnContents = slnTemplate.Replace("__LIB_PROJECT_GUID__", expectedLibProjectGuid); + + var matchingSrcFolder = slnFile.Projects + .Where((p) => p.FilePath == "src") + .ToList(); + if (matchingSrcFolder.Count == 1) + { + slnContents = slnContents.Replace("__SRC_FOLDER_GUID__", matchingSrcFolder[0].Id); + } + + var matchingSolutionFolder = slnFile.Projects + .Where((p) => p.FilePath == "TestFolder") + .ToList(); + if (matchingSolutionFolder.Count == 1) + { + slnContents = slnContents.Replace("__SOLUTION_FOLDER_GUID__", matchingSolutionFolder[0].Id); + } + + return slnContents; + } + } +}