Skip to content

Commit

Permalink
Fix #27536 and #26395
Browse files Browse the repository at this point in the history
When building project, GlobalProperties should be always copied from parent project (or parent engine, since they are the same).
  • Loading branch information
vestild committed Mar 1, 2015
1 parent 2b9b9d6 commit c40df43
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,20 +270,19 @@ public bool BuildProjectFile (string projectFile)
newProject = true;
}

BuildPropertyGroup engine_old_grp = null;
BuildPropertyGroup project_old_grp = null;
BuildPropertyGroup engine_old_grp = GlobalProperties.Clone (true);
BuildPropertyGroup project_old_grp = project.GlobalProperties.Clone (true);
foreach (BuildProperty bp in GlobalProperties)
project.GlobalProperties.AddProperty (bp);
if (globalProperties != null) {
engine_old_grp = GlobalProperties.Clone (true);
project_old_grp = project.GlobalProperties.Clone (true);

// Override project's global properties with the
// ones explicitlcur_y specified here
foreach (BuildProperty bp in globalProperties)
project.GlobalProperties.AddProperty (bp);

if (!newProject)
project.NeedToReevaluate ();
}
if (!newProject)
project.NeedToReevaluate ();

if (newProject)
project.Load (projectFile);
Expand All @@ -305,10 +304,8 @@ public bool BuildProjectFile (string projectFile)
project.ToolsVersion = oldProjectToolsVersion;
}
} finally {
if (globalProperties != null) {
GlobalProperties = engine_old_grp;
project.GlobalProperties = project_old_grp;
}
GlobalProperties = engine_old_grp;
project.GlobalProperties = project_old_grp;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,40 @@ public void TestGlobalProperties4c ()
"second"});
}

[Test]
public void TestGlobalProperties5 ()
{
string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ GetUsingTask ("MSBuild")
+ @"
<Target Name=""main"">
<MSBuild Projects=""second.proj"" Targets = ""TargetA""/>
<MSBuild Projects=""first.proj"" Targets = ""1"" Properties=""External=FirstExternalValue""/>
</Target>
</Project>";

string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ GetUsingTask ("MSBuild")
+ @"
<Target Name = ""1"">
<MSBuild Projects=""second.proj"" Properties=""foo=bar""/>
</Target>
</Project>
";

BuildPropertyGroup globalprops = new BuildPropertyGroup ();
globalprops.SetProperty ("External", "EngineExternalValue");

BuildPropertyGroup project_globalprops = new BuildPropertyGroup ();

CreateAndCheckGlobalPropertiesTest (mainProject, firstProject, secondProject,
globalprops, project_globalprops,
4, 4, 5,
new string [] {
"(TargetA) foo: A: External: EngineExternalValue",
"(TargetA) foo: bar A: External: FirstExternalValue"});
}

// Check for global properties in case of Import

[Test]
Expand Down

0 comments on commit c40df43

Please sign in to comment.