Skip to content

Commit

Permalink
Added test for .user file in outer build
Browse files Browse the repository at this point in the history
  • Loading branch information
maridematte committed Nov 28, 2023
1 parent 771a51c commit 10415e0
Showing 1 changed file with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,46 @@ public void OutputPathDoesNotHaveDuplicatedBackslashesInOuterBuild()
string outputPathValue = File.ReadAllText(Path.Combine(testAsset.TestRoot, testProject.Name, "OutputPathValue.txt"));
outputPathValue.Trim().Should().NotContain("\\\\");
}

[Fact]
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"));
outputPathValue.Should().Contain("User value is: A User defined value");
}
}
}

0 comments on commit 10415e0

Please sign in to comment.