Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,46 @@ public void OutputPathDoesNotHaveDuplicatedBackslashesInOuterBuild()
string outputPathValue = File.ReadAllText(Path.Combine(testAsset.TestRoot, testProject.Name, "OutputPathValue.txt"));
outputPathValue.Trim().Should().NotContain("\\\\");
}

[RequiresMSBuildVersionFact("17.9.0.61803")]
public void OuterBuildImportsUserFile()
{
var testProject = new TestProject()
{
TargetFrameworks = $"{ToolsetInfo.CurrentTargetFramework};net7.0"
};

testProject.ProjectChanges.Add(xml =>
{
var target = """
<Target Name="WriteValue" AfterTargets="Build">
<WriteLinesToFile File="$(MSBuildProjectDirectory)\OutputPathValue.txt"
Lines="User value is: $(UserValue)"
Overwrite="true" />
</Target>
""";

xml.Root.Add(XElement.Parse(target));
});

string temp = $"{testProject.Name}.csproj.user";
testProject.SourceFiles[temp] = """
<Project>
<PropertyGroup>
<UserValue>A User defined value</UserValue>
</PropertyGroup>
</Project>
""";

var testAsset = _testAssetsManager.CreateTestProject(testProject);

new BuildCommand(testAsset)
.Execute()
.Should()
.Pass();

string outputPathValue = File.ReadAllText(Path.Combine(testAsset.TestRoot, testProject.Name, "OutputPathValue.txt"));
Copy link
Member

Choose a reason for hiding this comment

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

This file could have been created by inner builds, though, right? Though I guess since this is after Build, the outer build would have overwritten it with an empty one . . .

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, the file will be created by the inner builds too, but the outer one will be the last and will override whatever is there.

outputPathValue.Should().Contain("User value is: A User defined value");
}
}
}