Honor CopyBuildOutputToPublishDirectory and CopyOutputSymbolsToPublishDirectory switches
Fixes #204
This commit is contained in:
parent
05d077da43
commit
311c52b12e
|
|
@ -170,11 +170,15 @@
|
||||||
Remove="%(MvcRazorFilesToCompile.FullPath)"
|
Remove="%(MvcRazorFilesToCompile.FullPath)"
|
||||||
Condition="'$(MvcRazorExcludeViewFilesFromPublish)'=='true'" />
|
Condition="'$(MvcRazorExcludeViewFilesFromPublish)'=='true'" />
|
||||||
|
|
||||||
<ResolvedFileToPublish Include="$(_MvcRazorOutputFullPath)" CopyToPublishDirectory="Always" Condition="Exists('$(_MvcRazorOutputFullPath)')">
|
<ResolvedFileToPublish Include="$(_MvcRazorOutputFullPath)"
|
||||||
|
CopyToPublishDirectory="Always"
|
||||||
|
Condition="'$(CopyBuildOutputToPublishDirectory)'=='true' AND Exists('$(_MvcRazorOutputFullPath)')">
|
||||||
<RelativePath>$([System.IO.Path]::GetFileName('$(_MvcRazorOutputFullPath)'))</RelativePath>
|
<RelativePath>$([System.IO.Path]::GetFileName('$(_MvcRazorOutputFullPath)'))</RelativePath>
|
||||||
</ResolvedFileToPublish>
|
</ResolvedFileToPublish>
|
||||||
|
|
||||||
<ResolvedFileToPublish Include="$(_MvcRazorOutputPdbFullPath)" CopyToPublishDirectory="Always" Condition="Exists('$(_MvcRazorOutputPdbFullPath)')">
|
<ResolvedFileToPublish Include="$(_MvcRazorOutputPdbFullPath)"
|
||||||
|
CopyToPublishDirectory="Always"
|
||||||
|
Condition="'$(CopyOutputSymbolsToPublishDirectory)'=='true'AND Exists('$(_MvcRazorOutputPdbFullPath)')">
|
||||||
<RelativePath>$([System.IO.Path]::GetFileName('$(_MvcRazorOutputPdbFullPath)'))</RelativePath>
|
<RelativePath>$([System.IO.Path]::GetFileName('$(_MvcRazorOutputPdbFullPath)'))</RelativePath>
|
||||||
</ResolvedFileToPublish>
|
</ResolvedFileToPublish>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||||
|
using Microsoft.AspNetCore.Testing.xunit;
|
||||||
|
using Microsoft.Extensions.Logging.Testing;
|
||||||
|
using Xunit;
|
||||||
|
using Xunit.Abstractions;
|
||||||
|
|
||||||
|
namespace FunctionalTests
|
||||||
|
{
|
||||||
|
[OSSkipCondition(OperatingSystems.Linux)]
|
||||||
|
[OSSkipCondition(OperatingSystems.MacOSX)]
|
||||||
|
public class CopyBuildOutputToPublishDirectoryTest_Desktop :
|
||||||
|
LoggedTest, IClassFixture<CopyBuildOutputToPublishDirectoryTest_Desktop.TestFixture>
|
||||||
|
{
|
||||||
|
public CopyBuildOutputToPublishDirectoryTest_Desktop(
|
||||||
|
TestFixture fixture,
|
||||||
|
ITestOutputHelper output)
|
||||||
|
: base(output)
|
||||||
|
{
|
||||||
|
Fixture = fixture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationTestFixture Fixture { get; }
|
||||||
|
|
||||||
|
[ConditionalFact]
|
||||||
|
public async Task PublishingWithOption_SkipsPublishingPrecompiledDll()
|
||||||
|
{
|
||||||
|
using (StartLog(out var loggerFactory))
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
|
||||||
|
|
||||||
|
// Act & Assert
|
||||||
|
var dllFile = Path.Combine(deployment.ContentRoot, "SimpleApp.PrecompiledViews.dll");
|
||||||
|
var pdbFile = Path.ChangeExtension(dllFile, ".pdb");
|
||||||
|
Assert.False(File.Exists(dllFile), $"{dllFile} exists at deployment.");
|
||||||
|
Assert.True(File.Exists(pdbFile), $"{pdbFile} does not exist at deployment.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TestFixture : DesktopApplicationTestFixture<SimpleApp.Startup>
|
||||||
|
{
|
||||||
|
public TestFixture()
|
||||||
|
{
|
||||||
|
PublishOnly = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DeploymentParameters GetDeploymentParameters()
|
||||||
|
{
|
||||||
|
var deploymentParameters = base.GetDeploymentParameters();
|
||||||
|
deploymentParameters.PublishEnvironmentVariables.Add(
|
||||||
|
new KeyValuePair<string, string>("CopyBuildOutputToPublishDirectory", "false"));
|
||||||
|
|
||||||
|
return deploymentParameters;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||||
|
using Microsoft.Extensions.Logging.Testing;
|
||||||
|
using Xunit;
|
||||||
|
using Xunit.Abstractions;
|
||||||
|
|
||||||
|
namespace FunctionalTests
|
||||||
|
{
|
||||||
|
public class CopyBuildOutputToPublishDirectory_CoreCLR :
|
||||||
|
LoggedTest, IClassFixture<CopyBuildOutputToPublishDirectory_CoreCLR.TestFixture>
|
||||||
|
{
|
||||||
|
public CopyBuildOutputToPublishDirectory_CoreCLR(
|
||||||
|
TestFixture fixture,
|
||||||
|
ITestOutputHelper output)
|
||||||
|
: base(output)
|
||||||
|
{
|
||||||
|
Fixture = fixture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationTestFixture Fixture { get; }
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task PublishingWithOption_SkipsPublishingPrecompiledDll()
|
||||||
|
{
|
||||||
|
using (StartLog(out var loggerFactory))
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
|
||||||
|
|
||||||
|
// Act & Assert
|
||||||
|
var dllFile = Path.Combine(deployment.ContentRoot, "SimpleApp.PrecompiledViews.dll");
|
||||||
|
var pdbFile = Path.ChangeExtension(dllFile, ".pdb");
|
||||||
|
Assert.False(File.Exists(dllFile), $"{dllFile} exists at deployment.");
|
||||||
|
Assert.True(File.Exists(pdbFile), $"{pdbFile} does not exist at deployment.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TestFixture : CoreCLRApplicationTestFixture<SimpleApp.Startup>
|
||||||
|
{
|
||||||
|
public TestFixture()
|
||||||
|
{
|
||||||
|
PublishOnly = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DeploymentParameters GetDeploymentParameters()
|
||||||
|
{
|
||||||
|
var deploymentParameters = base.GetDeploymentParameters();
|
||||||
|
deploymentParameters.PublishEnvironmentVariables.Add(
|
||||||
|
new KeyValuePair<string, string>("CopyBuildOutputToPublishDirectory", "false"));
|
||||||
|
|
||||||
|
return deploymentParameters;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||||
|
using Microsoft.Extensions.Logging.Testing;
|
||||||
|
using Xunit;
|
||||||
|
using Xunit.Abstractions;
|
||||||
|
|
||||||
|
namespace FunctionalTests
|
||||||
|
{
|
||||||
|
public class CopyOutputSymbolsToPublishDirectoryTest_CoreCLR :
|
||||||
|
LoggedTest, IClassFixture<CopyOutputSymbolsToPublishDirectoryTest_CoreCLR.TestFixture>
|
||||||
|
{
|
||||||
|
public CopyOutputSymbolsToPublishDirectoryTest_CoreCLR(
|
||||||
|
TestFixture fixture,
|
||||||
|
ITestOutputHelper output)
|
||||||
|
: base(output)
|
||||||
|
{
|
||||||
|
Fixture = fixture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationTestFixture Fixture { get; }
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task PublishingWithOption_SkipsPublishingPdb()
|
||||||
|
{
|
||||||
|
using (StartLog(out var loggerFactory))
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
|
||||||
|
|
||||||
|
// Act & Assert
|
||||||
|
var dllFile = Path.Combine(deployment.ContentRoot, "SimpleApp.PrecompiledViews.dll");
|
||||||
|
var pdbFile = Path.ChangeExtension(dllFile, ".pdb");
|
||||||
|
Assert.True(File.Exists(dllFile), $"{dllFile} does not exist at deployment.");
|
||||||
|
Assert.False(File.Exists(pdbFile), $"{pdbFile} exists at deployment.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TestFixture : CoreCLRApplicationTestFixture<SimpleApp.Startup>
|
||||||
|
{
|
||||||
|
public TestFixture()
|
||||||
|
{
|
||||||
|
PublishOnly = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DeploymentParameters GetDeploymentParameters()
|
||||||
|
{
|
||||||
|
var deploymentParameters = base.GetDeploymentParameters();
|
||||||
|
deploymentParameters.PublishEnvironmentVariables.Add(
|
||||||
|
new KeyValuePair<string, string>("CopyOutputSymbolsToPublishDirectory", "false"));
|
||||||
|
|
||||||
|
return deploymentParameters;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||||
|
using Microsoft.AspNetCore.Testing.xunit;
|
||||||
|
using Microsoft.Extensions.Logging.Testing;
|
||||||
|
using Xunit;
|
||||||
|
using Xunit.Abstractions;
|
||||||
|
|
||||||
|
namespace FunctionalTests
|
||||||
|
{
|
||||||
|
[OSSkipCondition(OperatingSystems.Linux)]
|
||||||
|
[OSSkipCondition(OperatingSystems.MacOSX)]
|
||||||
|
public class CopyOutputSymbolsToPublishDirectoryTest_Desktop :
|
||||||
|
LoggedTest, IClassFixture<CopyOutputSymbolsToPublishDirectoryTest_Desktop.TestFixture>
|
||||||
|
{
|
||||||
|
public CopyOutputSymbolsToPublishDirectoryTest_Desktop(
|
||||||
|
TestFixture fixture,
|
||||||
|
ITestOutputHelper output)
|
||||||
|
: base(output)
|
||||||
|
{
|
||||||
|
Fixture = fixture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationTestFixture Fixture { get; }
|
||||||
|
|
||||||
|
[ConditionalFact]
|
||||||
|
public async Task PublishingWithOption_SkipsPublishingPdb()
|
||||||
|
{
|
||||||
|
using (StartLog(out var loggerFactory))
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
|
||||||
|
|
||||||
|
// Act & Assert
|
||||||
|
var dllFile = Path.Combine(deployment.ContentRoot, "SimpleApp.PrecompiledViews.dll");
|
||||||
|
var pdbFile = Path.ChangeExtension(dllFile, ".pdb");
|
||||||
|
Assert.True(File.Exists(dllFile), $"{dllFile} does not exist at deployment.");
|
||||||
|
Assert.False(File.Exists(pdbFile), $"{pdbFile} exists at deployment.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TestFixture : DesktopApplicationTestFixture<SimpleApp.Startup>
|
||||||
|
{
|
||||||
|
public TestFixture()
|
||||||
|
{
|
||||||
|
PublishOnly = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DeploymentParameters GetDeploymentParameters()
|
||||||
|
{
|
||||||
|
var deploymentParameters = base.GetDeploymentParameters();
|
||||||
|
deploymentParameters.PublishEnvironmentVariables.Add(
|
||||||
|
new KeyValuePair<string, string>("CopyOutputSymbolsToPublishDirectory", "false"));
|
||||||
|
|
||||||
|
return deploymentParameters;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -26,6 +26,8 @@ namespace FunctionalTests
|
||||||
|
|
||||||
public string ApplicationPath { get; }
|
public string ApplicationPath { get; }
|
||||||
|
|
||||||
|
public bool PublishOnly { get; set; }
|
||||||
|
|
||||||
protected abstract DeploymentParameters GetDeploymentParameters();
|
protected abstract DeploymentParameters GetDeploymentParameters();
|
||||||
|
|
||||||
protected DeploymentParameters GetDeploymentParameters(RuntimeFlavor flavor)
|
protected DeploymentParameters GetDeploymentParameters(RuntimeFlavor flavor)
|
||||||
|
|
@ -77,7 +79,15 @@ namespace FunctionalTests
|
||||||
if (_deploymentTask == null)
|
if (_deploymentTask == null)
|
||||||
{
|
{
|
||||||
var deploymentParameters = GetDeploymentParameters();
|
var deploymentParameters = GetDeploymentParameters();
|
||||||
_deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory);
|
if (PublishOnly)
|
||||||
|
{
|
||||||
|
_deployer = new PublishOnlyDeployer(deploymentParameters, loggerFactory);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory);
|
||||||
|
}
|
||||||
|
|
||||||
_deploymentTask = _deployer.DeployAsync();
|
_deploymentTask = _deployer.DeployAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Server.IntegrationTesting.Common;
|
||||||
|
using Microsoft.AspNetCore.Testing;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
||||||
|
{
|
||||||
|
public class PublishOnlyDeployer : SelfHostDeployer
|
||||||
|
{
|
||||||
|
public PublishOnlyDeployer(DeploymentParameters deploymentParameters, ILoggerFactory loggerFactory)
|
||||||
|
: base(deploymentParameters, loggerFactory)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Task<DeploymentResult> DeployAsync()
|
||||||
|
{
|
||||||
|
using (Logger.BeginScope("SelfHost.Deploy"))
|
||||||
|
{
|
||||||
|
// Start timer
|
||||||
|
StartTimer();
|
||||||
|
|
||||||
|
if (DeploymentParameters.PublishApplicationBeforeDeployment)
|
||||||
|
{
|
||||||
|
DotnetPublish();
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = new DeploymentResult(
|
||||||
|
LoggerFactory,
|
||||||
|
DeploymentParameters,
|
||||||
|
applicationBaseUri: "http://localhost",
|
||||||
|
contentRoot: DeploymentParameters.PublishApplicationBeforeDeployment ? DeploymentParameters.PublishedApplicationRootPath : DeploymentParameters.ApplicationPath,
|
||||||
|
hostShutdownToken: default(CancellationToken));
|
||||||
|
|
||||||
|
return Task.FromResult(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -39,6 +39,11 @@ namespace FunctionalTests
|
||||||
|
|
||||||
public class TestFixture : CoreCLRApplicationTestFixture<SimpleApp.Startup>
|
public class TestFixture : CoreCLRApplicationTestFixture<SimpleApp.Startup>
|
||||||
{
|
{
|
||||||
|
public TestFixture()
|
||||||
|
{
|
||||||
|
PublishOnly = true;
|
||||||
|
}
|
||||||
|
|
||||||
protected override DeploymentParameters GetDeploymentParameters()
|
protected override DeploymentParameters GetDeploymentParameters()
|
||||||
{
|
{
|
||||||
var deploymentParameters = base.GetDeploymentParameters();
|
var deploymentParameters = base.GetDeploymentParameters();
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,11 @@ namespace FunctionalTests
|
||||||
|
|
||||||
public class TestFixture : DesktopApplicationTestFixture<SimpleApp.Startup>
|
public class TestFixture : DesktopApplicationTestFixture<SimpleApp.Startup>
|
||||||
{
|
{
|
||||||
|
public TestFixture()
|
||||||
|
{
|
||||||
|
PublishOnly = true;
|
||||||
|
}
|
||||||
|
|
||||||
protected override DeploymentParameters GetDeploymentParameters()
|
protected override DeploymentParameters GetDeploymentParameters()
|
||||||
{
|
{
|
||||||
var deploymentParameters = base.GetDeploymentParameters();
|
var deploymentParameters = base.GetDeploymentParameters();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue