diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackTool.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackTool.targets index 9a0559a03a4d..6566bebb20ef 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackTool.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackTool.targets @@ -51,28 +51,38 @@ NOTE: This file is imported from the following contexts, so be aware when writin <_UserSpecifiedToolPackageRids Condition="'$(_UserSpecifiedToolPackageRids)' == ''">$(RuntimeIdentifiers) <_HasRIDSpecificTools Condition=" '$(_UserSpecifiedToolPackageRids)' != '' ">true <_HasRIDSpecificTools Condition="'$(_HasRIDSpecificTools)' == ''">false + + $(_UserSpecifiedToolPackageRids);$(PackAsToolShimRuntimeIdentifiers) <_IsRidSpecific>false <_IsRidSpecific Condition="'$(RuntimeIdentifier)' != '' and '$(RuntimeIdentifier)' != 'any'">true - - - - - false - - false - false - false - false - + Knowing this lets us correctly decide to create the RID-specific inner tools or not when packaging the outer tool. --> <_InnerToolsPublishAot>false <_InnerToolsPublishAot Condition="$(_HasRIDSpecificTools) and '$(PublishAot)' == 'true'">true - false + + + <_IsImplicitRestore>false + <_IsImplicitRestore Condition="'$(MSBuildIsRestoring)' == 'true'">true + <_IsPacking Condition="'$(_IsPacking)' == ''">false + + + false + false + false + false + false + false @@ -82,11 +92,13 @@ NOTE: This file is imported from the following contexts, so be aware when writin <_ToolPackageShouldIncludeImplementation Condition="'$(_ToolPackageShouldIncludeImplementation)' == ''">false - <_PackToolPublishDependency Condition=" '$(_ToolPackageShouldIncludeImplementation)' != '' and '$(GeneratePackageOnBuild)' != 'true' and $(IsPublishable) == 'true' ">Publish + <_PackToolPublishDependency Condition=" $(_ToolPackageShouldIncludeImplementation) and '$(GeneratePackageOnBuild)' != 'true' and $(IsPublishable) == 'true' ">Publish - <_PackToolPublishDependency Condition=" '$(_ToolPackageShouldIncludeImplementation)' != '' and '$(GeneratePackageOnBuild)' == 'true' and $(IsPublishable) == 'true' ">$(_PublishNoBuildAlternativeDependsOn) + <_PackToolPublishDependency Condition=" $(_ToolPackageShouldIncludeImplementation) and '$(GeneratePackageOnBuild)' == 'true' and $(IsPublishable) == 'true' ">$(_PublishNoBuildAlternativeDependsOn) + + <_PackToolPublishDependency Condition="!$(_ToolPackageShouldIncludeImplementation)"> @@ -105,7 +105,7 @@ Copyright (c) .NET Foundation. All rights reserved. '$(RuntimeIdentifier)' == '' and '$(_IsExecutable)' == 'true' and '$(IsRidAgnostic)' != 'true' and - '$(PackAsTool)' != true and + ('$(PackAsTool)' != 'true' or '$(_IsPacking)' != 'true') and ( '$(SelfContained)' == 'true' or ('$(_IsPublishing)' == 'true' and @@ -216,10 +216,8 @@ Copyright (c) .NET Foundation. All rights reserved. $([MSBuild]::VersionLessThan('$(_TargetFrameworkVersionWithoutV)', '5.0'))">$(DefaultAppHostRuntimeIdentifier.Replace("arm64", "x64")) - - + + + + + + false false false + false false false diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithoutTransitiveProjectRefs.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithoutTransitiveProjectRefs.cs index 74de1a348826..57f2fc797cdc 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithoutTransitiveProjectRefs.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithoutTransitiveProjectRefs.cs @@ -29,6 +29,9 @@ public void It_builds_the_project_successfully_with_static_graph_and_isolation() public void It_cleans_the_project_successfully_with_static_graph_and_isolation() { var (testAsset, outputDirectories) = BuildAppWithTransitiveDependenciesAndTransitiveCompileReference(new[] { "/graph", "/bl:build-{}.binlog" }); + var binlogDestPath = Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT") is { } ciOutputRoot && Environment.GetEnvironmentVariable("HELIX_WORKITEM_ID") is { } helixGuid ? + Path.Combine(ciOutputRoot, "binlog", helixGuid, $"{nameof(It_cleans_the_project_successfully_with_static_graph_and_isolation)}.binlog") : + "./msbuild.binlog"; var cleanCommand = new DotnetCommand( Log, @@ -36,7 +39,7 @@ public void It_cleans_the_project_successfully_with_static_graph_and_isolation() Path.Combine(testAsset.TestRoot, "1", "1.csproj"), "/t:clean", "/graph", - "/bl:clean-{}.binlog"); + $"/bl:{binlogDestPath}"); cleanCommand .Execute() @@ -175,12 +178,16 @@ public void It_builds_the_project_successfully_when_RAR_does_not_find_all_refere private (CommandResult BuildResult, IReadOnlyDictionary OutputDirectories) Build( TestAsset testAsset, IEnumerable targetFrameworks, - string[] msbuildArguments + string[] msbuildArguments, + [CallerMemberName] string callingMethod = "" ) { var buildCommand = new BuildCommand(testAsset, "1"); buildCommand.WithWorkingDirectory(testAsset.TestRoot); - var buildResult = buildCommand.ExecuteWithoutRestore(msbuildArguments); + var binlogDestPath = Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT") is { } ciOutputRoot && Environment.GetEnvironmentVariable("HELIX_WORKITEM_ID") is { } helixGuid ? + Path.Combine(ciOutputRoot, "binlog", helixGuid, $"{callingMethod}.binlog") : + "./msbuild.binlog"; + var buildResult = buildCommand.ExecuteWithoutRestore([..msbuildArguments, $"/bl:{binlogDestPath}"]); var outputDirectories = targetFrameworks.ToImmutableDictionary(tf => tf, tf => buildCommand.GetOutputDirectory(tf)); diff --git a/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishASingleFileApp.cs b/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishASingleFileApp.cs index 6f917540cbc1..d8a821397e42 100644 --- a/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishASingleFileApp.cs +++ b/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishASingleFileApp.cs @@ -736,7 +736,7 @@ public void EnableSingleFile_warns_when_expected_for_not_correctly_multitargeted testProject.AdditionalProperties["CheckEolTargetFramework"] = "false"; // Silence warning about targeting EOL TFMs var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFrameworks) .WithProjectChanges(AddTargetFrameworkAliases); - + var buildCommand = new BuildCommand(testAsset); var resultAssertion = buildCommand.Execute("/p:CheckEolTargetFramework=false") .Should().Pass(); @@ -853,9 +853,14 @@ public void It_can_disable_cetcompat(bool? cetCompat) testProject.AdditionalProperties.Add("CetCompat", cetCompat.ToString()); } + var binlogDestPath = Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT") is { } ciOutputRoot && Environment.GetEnvironmentVariable("HELIX_WORKITEM_ID") is { } helixGuid ? + Path.Combine(ciOutputRoot, "binlog", helixGuid, $"{nameof(It_can_disable_cetcompat)}_{cetCompat?.ToString() ?? "null"}.binlog") : + "./msbuild.binlog"; + + var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: cetCompat.HasValue ? cetCompat.Value.ToString() : "default"); var publishCommand = new PublishCommand(testAsset); - publishCommand.Execute(PublishSingleFile) + publishCommand.Execute(PublishSingleFile, "/bl:" + binlogDestPath) .Should() .Pass(); diff --git a/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAToolProject.cs b/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAToolProject.cs index 18d4f9d2390a..b9bca0e339e7 100644 --- a/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAToolProject.cs +++ b/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAToolProject.cs @@ -10,6 +10,12 @@ namespace Microsoft.NET.Publish.Tests { public class GivenThatWeWantToPublishAToolProject : SdkTest { + + public static string HostfxrName = + RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "hostfxr.dll" : + RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "libhostfxr.so" : + "libhostfxr.dylib"; + public GivenThatWeWantToPublishAToolProject(ITestOutputHelper log) : base(log) { } @@ -37,5 +43,24 @@ public void It_can_publish_and_has_apphost() publishCommand.GetOutputDirectory(targetFramework: ToolsetInfo.CurrentTargetFramework) .Should().HaveFile("consoledemo" + Constants.ExeSuffix); } + + [Fact] + // this test verifies that we don't regress the 'normal' publish experience accidentally in the + // PackTool.targets + public void It_can_publish_selfcontained_and_has_apphost() + { + var testAsset = SetupTestAsset().SetProjProperty("PublishSelfContained", "true"); + var publishCommand = new PublishCommand(testAsset); + + var binlogDestPath = Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT") is { } ciOutputRoot ? + Path.Combine(ciOutputRoot, "binlog", $"{nameof(It_can_publish_selfcontained_and_has_apphost)}.binlog") : + "./msbuild.binlog"; + + publishCommand.WithWorkingDirectory(testAsset.Path).Execute($"-bl:{binlogDestPath}"); + + publishCommand.GetOutputDirectory(targetFramework: ToolsetInfo.CurrentTargetFramework, runtimeIdentifier: System.Runtime.InteropServices.RuntimeInformation.RuntimeIdentifier) + .Should().HaveFile("consoledemo" + Constants.ExeSuffix) + .And.HaveFile(HostfxrName); + } } } diff --git a/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishIncrementally.cs b/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishIncrementally.cs index c34806bd2fad..c47c60089692 100644 --- a/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishIncrementally.cs +++ b/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishIncrementally.cs @@ -62,11 +62,14 @@ public void It_cleans_between_renames() }; var testAsset = _testAssetsManager.CreateTestProject(testProject, testProject.Name); + var binlogDestPath = Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT") is { } ciOutputRoot && Environment.GetEnvironmentVariable("HELIX_WORKITEM_ID") is { } helixGuid ? + Path.Combine(ciOutputRoot, "binlog", helixGuid, $"{nameof(It_cleans_between_renames)}.binlog") : + "./msbuild.binlog"; // Publish as a single file var publishCommand = new PublishCommand(testAsset); publishCommand - .Execute(@"/p:PublishSingleFile=true") + .Execute(@"/p:PublishSingleFile=true", $"-bl:{binlogDestPath}") .Should() .Pass(); @@ -104,10 +107,14 @@ public void It_cleans_between_single_file_publishes() }; var testAsset = _testAssetsManager.CreateTestProject(testProject, testProject.Name); - // Publish as a single file - var publishCommand = new PublishCommand(testAsset); + var binlogDestPath = Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT") is { } ciOutputRoot && Environment.GetEnvironmentVariable("HELIX_WORKITEM_ID") is { } helixGuid ? + Path.Combine(ciOutputRoot, "binlog", helixGuid, $"{nameof(It_cleans_between_single_file_publishes)}.binlog") : + "./msbuild.binlog"; + + + var publishCommand = new PublishCommand(testAsset).WithWorkingDirectory(testAsset.Path) as PublishCommand; publishCommand - .Execute(@"/p:PublishSingleFile=true") + .Execute(@"/p:PublishSingleFile=true", $"-bl:{binlogDestPath}") .Should() .Pass(); diff --git a/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToRunILLink.cs b/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToRunILLink.cs index 9722cd14b919..2a038cb9a679 100644 --- a/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToRunILLink.cs +++ b/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToRunILLink.cs @@ -1662,8 +1662,14 @@ public void ILLink_can_treat_warnings_as_errors_independently(string targetFrame .And.NotHaveStdOutContaining("error IL2075"); } + /// + /// The reason we test this on net7 and below is because in net8 _IsPublishing was added which changes + /// the RID-defaulting behavior such that 8+ apps are not 'portable apps' when published for configurations that + /// require a RID (self-contained, or trimmed). + /// + /// [RequiresMSBuildVersionTheory("17.0.0.32901")] - [MemberData(nameof(SupportedTfms), MemberType = typeof(PublishTestUtils))] + [MemberData(nameof(TFMsThatDoNotInferPublishSelfContained), MemberType = typeof(PublishTestUtils))] public void ILLink_error_on_portable_app(string targetFramework) { var projectName = "HelloWorld"; diff --git a/test/Microsoft.NET.Publish.Tests/PublishTestUtils.cs b/test/Microsoft.NET.Publish.Tests/PublishTestUtils.cs index 53eb3fa79d4b..cadaff949c57 100644 --- a/test/Microsoft.NET.Publish.Tests/PublishTestUtils.cs +++ b/test/Microsoft.NET.Publish.Tests/PublishTestUtils.cs @@ -9,6 +9,9 @@ internal static class PublishTestUtils { #if NET10_0 + /// + /// This list should contain the TFMs that we're interested in validating publishing support for + /// public static IEnumerable SupportedTfms { get; } = new List { // Some tests started failing on net3.1 so disabling since this has been out of support for a while @@ -22,7 +25,9 @@ internal static class PublishTestUtils // new object[] { ToolsetInfo.NextTargetFramework }, }; - // This list should contain all supported TFMs after net5.0 + /// + /// This list should contain all supported TFMs after net5.0 + /// public static IEnumerable Net5Plus { get; } = new List { new object[] { "net5.0" }, @@ -34,7 +39,9 @@ internal static class PublishTestUtils // new object[] { ToolsetInfo.NextTargetFramework }, }; - // This list should contain all supported TFMs after net6.0 + /// + /// This list should contain all supported TFMs after net6.0 + /// public static IEnumerable Net6Plus { get; } = new List { new object[] { "net6.0" }, @@ -45,7 +52,9 @@ internal static class PublishTestUtils // new object[] { ToolsetInfo.NextTargetFramework }, }; - // This list should contain all supported TFMs after net7.0 + /// + /// This list should contain all supported TFMs after net7.0 + /// public static IEnumerable Net7Plus { get; } = new List { new object[] { "net7.0" }, @@ -55,7 +64,9 @@ internal static class PublishTestUtils // new object[] { ToolsetInfo.NextTargetFramework }, }; - // This list should contain all supported TFMs after net8.0 + /// + /// This list should contain all supported TFMs after net8.0 + /// public static IEnumerable Net8Plus { get; } = new List { new object[] { "net8.0" }, @@ -64,7 +75,9 @@ internal static class PublishTestUtils // new object[] { ToolsetInfo.NextTargetFramework }, }; - // This list should contain all supported TFMs after net9.0 + /// + /// This list should contain all supported TFMs after net9.0 + /// public static IEnumerable Net9Plus { get; } = new List { new object[] { "net9.0" }, @@ -72,13 +85,30 @@ internal static class PublishTestUtils // new object[] { ToolsetInfo.NextTargetFramework }, }; - // This list should contain all supported TFMs after net10.0 + /// + /// This list should contain all supported TFMs after net10.0 + /// public static IEnumerable Net10Plus { get; } = new List { new object[] { "net10.0" }, new object[] { ToolsetInfo.CurrentTargetFramework }, // new object[] { ToolsetInfo.NextTargetFramework }, }; + + /// + /// Starting in 8 we introduced made Publish* properties that imply SelfContained actually set SelfContained, + /// and that means RIDs are inferred when publishing these. This list should contain all TFMs that do not infer SelfContained + /// when PublishSelfContained or PublishSingleFile are set without an explicit SelfContained value. + /// + /// + /// Tried to be fancy here and compute this by stripping the NET8Plus items from the SupportedTfms list, + /// but that broke test explorer integration in devkit. + /// + public static IEnumerable TFMsThatDoNotInferPublishSelfContained => [ + ["net5.0"], + ["net6.0"], + ["net7.0"], + ]; #else #error If building for a newer TFM, please update the values above to include both the old and new TFMs. #endif diff --git a/test/Microsoft.NET.TestFramework/Commands/MSBuildCommand.cs b/test/Microsoft.NET.TestFramework/Commands/MSBuildCommand.cs index 020ef737a5bc..57e04deaced4 100644 --- a/test/Microsoft.NET.TestFramework/Commands/MSBuildCommand.cs +++ b/test/Microsoft.NET.TestFramework/Commands/MSBuildCommand.cs @@ -10,6 +10,7 @@ public class MSBuildCommand : TestCommand public string Target { get; } private readonly string _projectRootPath; + private readonly string[] _requiredArgs; public string ProjectRootPath => _projectRootPath; @@ -19,18 +20,19 @@ public class MSBuildCommand : TestCommand public string FullPathProjectFile => Path.Combine(ProjectRootPath, ProjectFile); - public MSBuildCommand(ITestOutputHelper log, string target, string projectRootPath, string? relativePathToProject = null) + public MSBuildCommand(ITestOutputHelper log, string target, string projectRootPath, string? relativePathToProject = null, params ReadOnlySpan requiredArgs) : base(log) { Target = target; _projectRootPath = projectRootPath; + _requiredArgs = requiredArgs.ToArray(); ProjectFile = FindProjectFile(ref _projectRootPath, relativePathToProject); } - public MSBuildCommand(TestAsset testAsset, string target, string? relativePathToProject = null) - : this(testAsset.Log, target, testAsset.TestRoot, relativePathToProject ?? testAsset.TestProject?.Name) + public MSBuildCommand(TestAsset testAsset, string target, string? relativePathToProject = null, params ReadOnlySpan requiredArgs) + : this(testAsset.Log, target, testAsset.TestRoot, relativePathToProject ?? testAsset.TestProject?.Name, requiredArgs) { TestAsset = testAsset; } @@ -132,6 +134,7 @@ public override CommandResult Execute(IEnumerable args) { args = new[] { "/restore" }.Concat(args); } + args = [.. _requiredArgs, .. args]; var command = base.Execute(args); diff --git a/test/Microsoft.NET.TestFramework/Commands/PackCommand.cs b/test/Microsoft.NET.TestFramework/Commands/PackCommand.cs index 5ea180ba8e01..d71efd8fc05d 100644 --- a/test/Microsoft.NET.TestFramework/Commands/PackCommand.cs +++ b/test/Microsoft.NET.TestFramework/Commands/PackCommand.cs @@ -6,15 +6,13 @@ namespace Microsoft.NET.TestFramework.Commands public sealed class PackCommand : MSBuildCommand { public PackCommand(ITestOutputHelper log, string projectPath, string? relativePathToProject = null) - : base(log, "Pack", projectPath, relativePathToProject) + : base(log, "Pack", projectPath, relativePathToProject, requiredArgs: "/p:_IsPacking=true") { - } public PackCommand(TestAsset testAsset, string? relativePathToProject = null) - : base(testAsset, "Pack", relativePathToProject) + : base(testAsset, "Pack", relativePathToProject, requiredArgs: "/p:_IsPacking=true") { - } public string GetIntermediateNuspecPath(string? packageId = null, string configuration = "Debug", string packageVersion = "1.0.0") diff --git a/test/Microsoft.NET.TestFramework/Commands/PublishCommand.cs b/test/Microsoft.NET.TestFramework/Commands/PublishCommand.cs index d03d788fb37d..8d18404c7ef4 100644 --- a/test/Microsoft.NET.TestFramework/Commands/PublishCommand.cs +++ b/test/Microsoft.NET.TestFramework/Commands/PublishCommand.cs @@ -9,17 +9,16 @@ public sealed class PublishCommand : MSBuildCommand { private const string PublishSubfolderName = "publish"; - // Encourage use of the other overload, which is generally simpler to use + // Encourage use of the other overload, which is generally simpler to use [EditorBrowsable(EditorBrowsableState.Never)] public PublishCommand(ITestOutputHelper log, string projectPath) - : base(log, "Publish", projectPath, relativePathToProject: null) + : base(log, "Publish", projectPath, relativePathToProject: null, requiredArgs: "/p:_IsPublishing=true") { } public PublishCommand(TestAsset testAsset, string? relativePathToProject = null) - : base(testAsset, "Publish", relativePathToProject) + : base(testAsset, "Publish", relativePathToProject, requiredArgs: "/p:_IsPublishing=true") { - } public override DirectoryInfo GetOutputDirectory(string? targetFramework = null, string configuration = "Debug", string? runtimeIdentifier = "", string? platformIdentifier = "") diff --git a/test/Microsoft.NET.TestFramework/TestAsset.cs b/test/Microsoft.NET.TestFramework/TestAsset.cs index 54b2ae2d5315..26eda24f928c 100644 --- a/test/Microsoft.NET.TestFramework/TestAsset.cs +++ b/test/Microsoft.NET.TestFramework/TestAsset.cs @@ -60,6 +60,10 @@ internal void FindProjectFiles() } } + /// + /// Copies all of the source code from the TestAsset's original location to the previously-configured destination directory. + /// + /// public TestAsset WithSource() { _projectFiles = new List(); @@ -131,6 +135,20 @@ public TestAsset UpdateProjProperty(string propertyName, string variableName, st }); } + public TestAsset SetProjProperty(string propertyName, string value) + { + return WithProjectChanges( + p => + { + if (p.Root is not null) + { + var ns = p.Root.Name.Namespace; + var pg = p.Root.Elements(ns + "PropertyGroup").First(); + pg.Add(new XElement(ns + propertyName, value)); + } + }); + } + public TestAsset ReplacePackageVersionVariable(string targetName, string targetValue) { var elementsWithVersionAttribute = new[] { "PackageReference", "Package", "Sdk" }; diff --git a/test/Microsoft.NET.TestFramework/TestAssetsManager.cs b/test/Microsoft.NET.TestFramework/TestAssetsManager.cs index 479a6b57254e..67bf81b1eca8 100644 --- a/test/Microsoft.NET.TestFramework/TestAssetsManager.cs +++ b/test/Microsoft.NET.TestFramework/TestAssetsManager.cs @@ -27,6 +27,10 @@ public TestAssetsManager(ITestOutputHelper log) TestAssetsRoot = testAssetsDirectory; } + /// + /// Creates a new 'bubble' for the given test asset project in a subdirectory + /// of the current test execution context, scoped by the calling method and optional unique identifier. + /// public TestAsset CopyTestAsset( string testProjectName, [CallerMemberName] string callingMethod = "", diff --git a/test/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolProjectWithPackagedShim.cs b/test/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolProjectWithPackagedShim.cs index 5a0a5296d95b..63dbc7a4a518 100644 --- a/test/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolProjectWithPackagedShim.cs +++ b/test/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolProjectWithPackagedShim.cs @@ -258,12 +258,15 @@ public void It_contains_shim_with_no_build(bool multiTarget, string targetFramew { var testAsset = CreateTestAsset(multiTarget, nameof(It_contains_shim_with_no_build) + multiTarget + targetFramework, targetFramework); - var buildCommand = new BuildCommand(testAsset); + var buildCommand = new BuildCommand(testAsset).WithWorkingDirectory(testAsset.Path); buildCommand.Execute().Should().Pass(); - var packCommand = new PackCommand(testAsset); + var packCommand = new PackCommand(testAsset).WithWorkingDirectory(testAsset.Path) as PackCommand; + var binlogDestPath = Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT") is { } ciOutputRoot ? + Path.Combine(ciOutputRoot, "binlog", $"{nameof(It_contains_shim_with_no_build)}_{multiTarget}_{targetFramework}.binlog") : + "./msbuild.binlog"; - packCommand.Execute("/p:NoBuild=true").Should().Pass(); + packCommand.Execute($"/p:NoBuild=true", $"/bl:{binlogDestPath}").Should().Pass(); var nugetPackage = packCommand.GetNuGetPackage(); using (var nupkgReader = new PackageArchiveReader(nugetPackage))