Skip to content

Commit

Permalink
Permit direct access to a SolutionFilterName property Fixes #6162 (#6171
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Forgind authored Mar 3, 2021
1 parent 95415a2 commit 4e1e167
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/Build/Construction/Solution/SolutionFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ internal int VisualStudioVersion
/// </summary>
public IReadOnlyDictionary<string, ProjectInSolution> ProjectsByGuid => new ReadOnlyDictionary<string, ProjectInSolution>(_projects);

/// <summary>
/// This is the read accessor for the solution filter file, if present. Set through FullPath.
/// </summary>
internal string SolutionFilterFilePath { get => _solutionFilterFile; }

/// <summary>
/// This is the read/write accessor for the solution file which we will parse. This
/// must be set before calling any other methods on this class.
Expand Down
4 changes: 3 additions & 1 deletion src/Build/Construction/Solution/SolutionProjectGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ internal class SolutionProjectGenerator
new Tuple<string, string>("SolutionExt", null),
new Tuple<string, string>("SolutionFileName", null),
new Tuple<string, string>("SolutionName", null),
new Tuple<string, string>("SolutionFilterName", null),
new Tuple<string, string>(SolutionPathPropertyName, null)
};

Expand Down Expand Up @@ -499,7 +500,7 @@ bool specifyProjectToolsVersion

string additionalProperties = string.Format(
CultureInfo.InvariantCulture,
"Configuration={0}; Platform={1}; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)",
"Configuration={0}; Platform={1}; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionFilterName=$(SolutionFilterName); SolutionPath=$(SolutionPath)",
EscapingUtilities.Escape(configurationName),
EscapingUtilities.Escape(platformName)
);
Expand Down Expand Up @@ -2291,6 +2292,7 @@ private void AddGlobalProperties(ProjectRootElement traversalProject)
globalProperties.AddProperty("SolutionExt", EscapingUtilities.Escape(Path.GetExtension(_solutionFile.FullPath)));
globalProperties.AddProperty("SolutionFileName", EscapingUtilities.Escape(Path.GetFileName(_solutionFile.FullPath)));
globalProperties.AddProperty("SolutionName", EscapingUtilities.Escape(Path.GetFileNameWithoutExtension(_solutionFile.FullPath)));
globalProperties.AddProperty("SolutionFilterName", EscapingUtilities.Escape(Path.GetFileNameWithoutExtension(_solutionFile.SolutionFilterFilePath ?? string.Empty)));

globalProperties.AddProperty(SolutionPathPropertyName, EscapingUtilities.Escape(Path.Combine(_solutionFile.SolutionFileDirectory, Path.GetFileName(_solutionFile.FullPath))));

Expand Down
4 changes: 2 additions & 2 deletions src/Deprecated/Engine/Solution/SolutionWrapperProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ bool specifyProjectToolsVersion

string additionalProperties = string.Format(
CultureInfo.InvariantCulture,
"Configuration={0}; Platform={1}; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)",
"Configuration={0}; Platform={1}; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionFilterName=$(SolutionFilterName); SolutionPath=$(SolutionPath)",
EscapingUtilities.Escape(configurationName),
EscapingUtilities.Escape(platformName)
);
Expand Down Expand Up @@ -1608,7 +1608,7 @@ Dictionary<int, List<ProjectInSolution>> projectsByDependencyLevel
BuildTask msbuildTask = newTarget.AddNewTask("MSBuild");
msbuildTask.Condition = buildItemReference + " != ''";
msbuildTask.SetParameterValue("Projects", buildItemReference);
msbuildTask.SetParameterValue("Properties", "Configuration=%(Configuration); Platform=%(Platform); BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)");
msbuildTask.SetParameterValue("Properties", "Configuration=%(Configuration); Platform=%(Platform); BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionFilterName=$(SolutionFilterName); SolutionPath=$(SolutionPath)");

if (!string.IsNullOrEmpty(subTargetName))
{
Expand Down
1 change: 1 addition & 0 deletions src/MSBuild/MSBuild/Microsoft.Build.CommonTypes.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -1796,6 +1796,7 @@ elementFormDefault="qualified">
<xs:element name="SolutionExt" type="msb:StringPropertyType" substitutionGroup="msb:Property"/>
<xs:element name="SolutionFileName" type="msb:StringPropertyType" substitutionGroup="msb:Property"/>
<xs:element name="SolutionName" type="msb:StringPropertyType" substitutionGroup="msb:Property"/>
<xs:element name="SolutionFilterName" type="msb:StringPropertyType" substitutionGroup="msb:Property"/>
<xs:element name="SolutionPath" type="msb:StringPropertyType" substitutionGroup="msb:Property"/>
<xs:element name="StartAction" type="msb:StringPropertyType" substitutionGroup="msb:Property"/>
<xs:element name="StartArguments" type="msb:StringPropertyType" substitutionGroup="msb:Property"/>
Expand Down
1 change: 1 addition & 0 deletions src/Tasks/Microsoft.Common.CurrentVersion.targets
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<PropertyGroup>
<DevEnvDir Condition="'$(DevEnvDir)'==''">*Undefined*</DevEnvDir>
<SolutionName Condition="'$(SolutionName)'==''">*Undefined*</SolutionName>
<SolutionFilterName Condition="'$(SolutionFilterName)'==''">*Undefined*</SolutionFilterName>
<!-- Example, MySolution -->
<SolutionFileName Condition="'$(SolutionFileName)'==''">*Undefined*</SolutionFileName>
<!-- Example, MySolution.sln -->
Expand Down

0 comments on commit 4e1e167

Please sign in to comment.