diff --git a/src/ProjectTemplates/test/Helpers/Project.cs b/src/ProjectTemplates/test/Helpers/Project.cs index 84ac99baa7..d25b5bd529 100644 --- a/src/ProjectTemplates/test/Helpers/Project.cs +++ b/src/ProjectTemplates/test/Helpers/Project.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -27,6 +26,9 @@ namespace Templates.Test.Helpers public static bool IsCIEnvironment => typeof(Project).Assembly.GetCustomAttributes() .Any(a => a.Key == "ContinuousIntegrationBuild"); + public static string ArtifactsLogDir => typeof(Project).Assembly.GetCustomAttributes() + .Single(a => a.Key == "ArtifactsLogDir")?.Value; + public SemaphoreSlim DotNetNewLock { get; set; } public SemaphoreSlim NodeLock { get; set; } public string ProjectName { get; set; } @@ -112,11 +114,6 @@ namespace Templates.Test.Helpers { Output.WriteLine("Publishing ASP.NET application..."); - // Workaround for issue with runtime store not yet being published - // https://github.com/aspnet/Home/issues/2254#issuecomment-339709628 - var extraArgs = "-p:PublishWithAspNetCoreTargetManifest=false"; - - // This is going to trigger a build, so we need to acquire the lock like in the other cases. // We want to take the node lock as some builds run NPM as part of the build and we want to make sure // it's run without interruptions. @@ -124,8 +121,9 @@ namespace Templates.Test.Helpers await effectiveLock.WaitAsync(); try { - var result = ProcessEx.Run(Output, TemplateOutputDir, DotNetMuxer.MuxerPathOrDefault(), $"publish -c Release {extraArgs}", packageOptions); + var result = ProcessEx.Run(Output, TemplateOutputDir, DotNetMuxer.MuxerPathOrDefault(), $"publish -c Release /bl", packageOptions); await result.Exited; + CaptureBinLogOnFailure(result); return result; } finally @@ -145,8 +143,9 @@ namespace Templates.Test.Helpers await effectiveLock.WaitAsync(); try { - var result = ProcessEx.Run(Output, TemplateOutputDir, DotNetMuxer.MuxerPathOrDefault(), "build -c Debug", packageOptions); + var result = ProcessEx.Run(Output, TemplateOutputDir, DotNetMuxer.MuxerPathOrDefault(), "build -c Debug /bl", packageOptions); await result.Exited; + CaptureBinLogOnFailure(result); return result; } finally @@ -507,6 +506,17 @@ namespace Templates.Test.Helpers } } + private void CaptureBinLogOnFailure(ProcessEx result) + { + if (result.ExitCode != 0 && !string.IsNullOrEmpty(ArtifactsLogDir)) + { + var sourceFile = Path.Combine(TemplateOutputDir, "msbuild.binlog"); + Assert.True(File.Exists(sourceFile), $"Log for '{ProjectName}' not found in '{sourceFile}'."); + var destination = Path.Combine(ArtifactsLogDir, ProjectName + ".binlog"); + File.Move(sourceFile, destination); + } + } + public override string ToString() => $"{ProjectName}: {TemplateOutputDir}"; } } diff --git a/src/ProjectTemplates/test/ProjectTemplates.Tests.csproj b/src/ProjectTemplates/test/ProjectTemplates.Tests.csproj index 2477b99577..b8797c1345 100644 --- a/src/ProjectTemplates/test/ProjectTemplates.Tests.csproj +++ b/src/ProjectTemplates/test/ProjectTemplates.Tests.csproj @@ -75,6 +75,11 @@ <_Parameter2>$(ArtifactsShippingPackagesDir) + + <_Parameter1>ArtifactsLogDir + <_Parameter2>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'log')) + + <_Parameter1>ArtifactsNonShippingPackagesDir <_Parameter2>$(ArtifactsNonShippingPackagesDir)