Skip to content

Commit

Permalink
Fixed 'Pass SolutionFilterName as a property' regression bug (#6234)
Browse files Browse the repository at this point in the history
- Pass SolutionFilterName as a property
- Add unit test
  • Loading branch information
Forgind authored Mar 11, 2021
1 parent 7bc761a commit 38da84d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions src/Build.UnitTests/Construction/SolutionProjectGenerator_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using Xunit;
using Xunit.Abstractions;
using Shouldly;
using Microsoft.Build.UnitTests.Shared;

namespace Microsoft.Build.UnitTests.Construction
{
Expand Down Expand Up @@ -749,6 +750,37 @@ public void SolutionConfigurationWithDependencies()
Helpers.VerifyAssertLineByLine(expected, solutionConfigurationContents);
}

/// <summary>
/// This test forces a metaproj to be generated as part of the build. Since metaproj files are not written to disk, it will fail if its cached form does not align
/// with the version that is being built as when a property is part of the version added to the cache, but that version is not passed to the BuildManager.
/// </summary>
[Fact]
public void SolutionGeneratingMetaproj()
{
using (TestEnvironment env = TestEnvironment.Create())
{
TransientTestFile proj1 = env.CreateFile("A.csproj", @"<Project><Target Name=""Printer""><Message Importance=""high"" Text=""print string"" /></Target></Project>");
TransientTestFile proj2 = env.CreateFile("B.csproj", @"<Project><Target Name=""Printer""><Message Importance=""high"" Text=""print string"" /></Target></Project>");
TransientTestFile proj3 = env.CreateFile("C.csproj", @"<Project><Target Name=""Printer""><Message Importance=""high"" Text=""print string"" /></Target></Project>");
TransientTestFile proj = env.CreateFile("mysln.sln",
@$"
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 11
Project(`{"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"}`) = `A`, `{proj1.Path}`, `{"{786E302A-96CE-43DC-B640-D6B6CC9BF6C0}"}`
EndProject
Project(`{"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"}`) = `B`, `{proj2.Path}`, `{"{881C1674-4ECA-451D-85B6-D7C59B7F16FA}"}`
ProjectSection(ProjectDependencies) = postProject
{"{4A727FF8-65F2-401E-95AD-7C8BBFBE3167}"} = {"{4A727FF8-65F2-401E-95AD-7C8BBFBE3167}"}
EndProjectSection
EndProject
Project(`{"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"}`) = `C`, `{proj3.Path}`, `{"{4A727FF8-65F2-401E-95AD-7C8BBFBE3167}"}`
EndProject
".Replace("`", "\""));
RunnerUtilities.ExecMSBuild("\"" + proj.Path + "\"", out bool successfulExit);
successfulExit.ShouldBeTrue();
}
}

/// <summary>
/// Generated project metaproj should declare its outputs for relay.
/// Here B depends on C (via solution dep only) and D (via ProjectReference only)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ internal class SolutionProjectGenerator
/// <summary>
/// The set of properties all projects in the solution should be built with
/// </summary>
private const string SolutionProperties = "BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)";
private const string SolutionProperties = "BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionFilterName=$(SolutionFilterName); SolutionPath=$(SolutionPath)";

/// <summary>
/// The set of properties which identify the configuration and platform to build a project with
Expand Down

0 comments on commit 38da84d

Please sign in to comment.