Skip to content

Commit cfd1af2

Browse files
committed
drop a binlog
1 parent 35e921b commit cfd1af2

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAToolProject.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@ public void It_can_publish_and_has_apphost()
4949
// PackTool.targets
5050
public void It_can_publish_selfcontained_and_has_apphost()
5151
{
52-
var testAsset = SetupTestAsset();
52+
var testAsset = SetupTestAsset().SetProjProperty("PublishSelfContained", "true");
5353
var publishCommand = new PublishCommand(testAsset);
5454

55-
publishCommand.WithWorkingDirectory(testAsset.Path).Execute("-bl", "-p", "PublishSelfContained=true");
55+
var binlogDestPath = Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT") is { } ciOutputRoot ?
56+
Path.Combine(ciOutputRoot, "binlog", $"{nameof(It_can_publish_selfcontained_and_has_apphost)}.binlog") :
57+
"./msbuild.binlog";
58+
59+
publishCommand.WithWorkingDirectory(testAsset.Path).Execute($"-bl:{binlogDestPath}");
5660

5761
publishCommand.GetOutputDirectory(targetFramework: ToolsetInfo.CurrentTargetFramework, runtimeIdentifier: System.Runtime.InteropServices.RuntimeInformation.RuntimeIdentifier)
5862
.Should().HaveFile("consoledemo" + Constants.ExeSuffix)

test/Microsoft.NET.TestFramework/TestAsset.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ internal void FindProjectFiles()
6060
}
6161
}
6262

63+
/// <summary>
64+
/// Copies all of the source code from the TestAsset's original location to the previously-configured destination directory.
65+
/// </summary>
66+
/// <returns></returns>
6367
public TestAsset WithSource()
6468
{
6569
_projectFiles = new List<string>();
@@ -131,6 +135,20 @@ public TestAsset UpdateProjProperty(string propertyName, string variableName, st
131135
});
132136
}
133137

138+
public TestAsset SetProjProperty(string propertyName, string value)
139+
{
140+
return WithProjectChanges(
141+
p =>
142+
{
143+
if (p.Root is not null)
144+
{
145+
var ns = p.Root.Name.Namespace;
146+
var pg = p.Root.Elements(ns + "PropertyGroup").First();
147+
pg.Add(new XElement(ns + propertyName, value));
148+
}
149+
});
150+
}
151+
134152
public TestAsset ReplacePackageVersionVariable(string targetName, string targetValue)
135153
{
136154
var elementsWithVersionAttribute = new[] { "PackageReference", "Package", "Sdk" };

test/Microsoft.NET.TestFramework/TestAssetsManager.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ public TestAssetsManager(ITestOutputHelper log)
2727
TestAssetsRoot = testAssetsDirectory;
2828
}
2929

30+
/// <summary>
31+
/// Creates a new 'bubble' for the given test asset project in a subdirectory
32+
/// of the current test execution context, scoped by the calling method and optional unique identifier.
33+
/// </summary>
3034
public TestAsset CopyTestAsset(
3135
string testProjectName,
3236
[CallerMemberName] string callingMethod = "",

0 commit comments

Comments
 (0)