Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass SolutionFilterName as a property #6234

Merged
merged 2 commits into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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}"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The email thread that started this had two project dependencies, does testing one project dependency cover the N project dependencies scenario?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I ran this test before and after the change, and it failed before and passed after.

What's important is that it has to build a metaproj.

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