parent
28172a3a3e
commit
daec40f2ba
|
|
@ -1,9 +1,8 @@
|
||||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<Target Name="_ResolveInputArguments">
|
<Target Name="_ResolveInputArguments">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<_MvcRazorOutputPath Condition="'$(MvcRazorOutputPath)'!=''">$([MSBuild]::EnsureTrailingSlash('$(MvcRazorOutputPath)'))</_MvcRazorOutputPath>
|
<MvcRazorOutputPath Condition="'$(MvcRazorOutputPath)'==''">$(IntermediateOutputPath)</MvcRazorOutputPath>
|
||||||
<_MvcRazorOutputPath Condition="'$(_MvcRazorOutputPath)'==''">$(IntermediateOutputPath)</_MvcRazorOutputPath>
|
<_MvcRazorOutputFullPath Condition="'$(_MvcRazorOutputFullPath)'==''">$([MSBuild]::EnsureTrailingSlash('$(MvcRazorOutputPath)'))$(AssemblyName).PrecompiledViews.dll</_MvcRazorOutputFullPath>
|
||||||
<_MvcRazorOutputFullPath>$(_MvcRazorOutputPath)$(AssemblyName).PrecompiledViews.dll</_MvcRazorOutputFullPath>
|
|
||||||
<_MvcRazorResponseFilePath>$(IntermediateOutputPath)microsoft.aspnetcore.mvc.razor.viewcompilation.rsp</_MvcRazorResponseFilePath>
|
<_MvcRazorResponseFilePath>$(IntermediateOutputPath)microsoft.aspnetcore.mvc.razor.viewcompilation.rsp</_MvcRazorResponseFilePath>
|
||||||
|
|
||||||
<MvcRazorContentRoot Condition="'$(MvcRazorContentRoot)'==''">$(MSBuildProjectDirectory)</MvcRazorContentRoot>
|
<MvcRazorContentRoot Condition="'$(MvcRazorContentRoot)'==''">$(MSBuildProjectDirectory)</MvcRazorContentRoot>
|
||||||
|
|
@ -25,7 +24,7 @@
|
||||||
<CallTarget Targets="_MvcRazorPrecompile" />
|
<CallTarget Targets="_MvcRazorPrecompile" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="_MvcRazorPrecompile" DependsOnTargets="_RunForCore;_RunForDesktop" />
|
<Target Name="_MvcRazorPrecompile" DependsOnTargets="_RunForCore;_RunForCoreWithRID;_RunForDesktop" />
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<_MvcViewCompilationTasksPath Condition="'$(_MvcViewCompilationTasksPath)'==''">$(MSBuildThisFileDirectory)$(MSBuildThisFileName).Tasks.dll</_MvcViewCompilationTasksPath>
|
<_MvcViewCompilationTasksPath Condition="'$(_MvcViewCompilationTasksPath)'==''">$(MSBuildThisFileDirectory)$(MSBuildThisFileName).Tasks.dll</_MvcViewCompilationTasksPath>
|
||||||
|
|
@ -60,6 +59,22 @@
|
||||||
<Exec Command="$(ExecArgs)" WorkingDirectory="$(MSBuildProjectDirectory)" />
|
<Exec Command="$(ExecArgs)" WorkingDirectory="$(MSBuildProjectDirectory)" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
|
<Target
|
||||||
|
Name="_RunForCoreWithRID"
|
||||||
|
DependsOnTargets="_ResolveInputArguments;_CreateResponseFileForMvcRazorPrecompile"
|
||||||
|
Condition="'$(TargetFrameworkIdentifier)'=='.NETCoreApp' AND '$(RuntimeIdentifier)'!=''">
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<_RazorCompilationProject Include="$(MSBuildProjectFullPath)">
|
||||||
|
<AdditionalProperties>RuntimeIdentifier=;MvcRazorOutputPath=$(MvcRazorOutputPath)</AdditionalProperties>
|
||||||
|
</_RazorCompilationProject>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<MSBuild
|
||||||
|
Projects="@(_RazorCompilationProject)"
|
||||||
|
Targets="Build;MvcRazorPrecompile" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
<Target
|
<Target
|
||||||
Name="_AddDesktopReferences"
|
Name="_AddDesktopReferences"
|
||||||
AfterTargets="ResolveLockFileReferences"
|
AfterTargets="ResolveLockFileReferences"
|
||||||
|
|
@ -109,7 +124,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<_ResponseFileLines Include="
|
<_ResponseFileLines Include="
|
||||||
$(MSBuildProjectDirectory);
|
$(MSBuildProjectDirectory);
|
||||||
--output-path=$(_MvcRazorOutputPath);
|
--output-path=$(MvcRazorOutputPath);
|
||||||
--application-name=$(AssemblyName);
|
--application-name=$(AssemblyName);
|
||||||
--content-root=$(MvcRazorContentRoot);" />
|
--content-root=$(MvcRazorContentRoot);" />
|
||||||
|
|
||||||
|
|
@ -144,7 +159,7 @@
|
||||||
|
|
||||||
<Target Name="_MvcRazorResolveFilesToCompute"
|
<Target Name="_MvcRazorResolveFilesToCompute"
|
||||||
AfterTargets="ComputeRefAssembliesToPublish"
|
AfterTargets="ComputeRefAssembliesToPublish"
|
||||||
Condition="'$(MvcRazorCompileOnPublish)'=='true' AND ('$(TargetFrameworkIdentifier)'!='.NETCoreApp' OR '$(RuntimeIdentifier)'=='')">
|
Condition="'$(MvcRazorCompileOnPublish)'=='true'">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<_MvcRazorOutputPdbFullPath>$([System.IO.Path]::ChangeExtension('$(_MvcRazorOutputFullPath)', '.pdb'))</_MvcRazorOutputPdbFullPath>
|
<_MvcRazorOutputPdbFullPath>$([System.IO.Path]::ChangeExtension('$(_MvcRazorOutputFullPath)', '.pdb'))</_MvcRazorOutputPdbFullPath>
|
||||||
|
|
|
||||||
|
|
@ -29,18 +29,21 @@ namespace FunctionalTests
|
||||||
protected abstract DeploymentParameters GetDeploymentParameters();
|
protected abstract DeploymentParameters GetDeploymentParameters();
|
||||||
|
|
||||||
protected DeploymentParameters GetDeploymentParameters(RuntimeFlavor flavor)
|
protected DeploymentParameters GetDeploymentParameters(RuntimeFlavor flavor)
|
||||||
|
=> GetDeploymentParameters(ApplicationPath, ApplicationName, flavor);
|
||||||
|
|
||||||
|
public static DeploymentParameters GetDeploymentParameters(string applicationPath, string applicationName, RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
var telemetryOptOut = new KeyValuePair<string, string>(
|
var telemetryOptOut = new KeyValuePair<string, string>(
|
||||||
DotnetCLITelemetryOptOut,
|
DotnetCLITelemetryOptOut,
|
||||||
"1");
|
"1");
|
||||||
|
|
||||||
var deploymentParameters = new DeploymentParameters(
|
var deploymentParameters = new DeploymentParameters(
|
||||||
ApplicationPath,
|
applicationPath,
|
||||||
ServerType.Kestrel,
|
ServerType.Kestrel,
|
||||||
flavor,
|
flavor,
|
||||||
RuntimeArchitecture.x64)
|
RuntimeArchitecture.x64)
|
||||||
{
|
{
|
||||||
ApplicationName = ApplicationName,
|
ApplicationName = applicationName,
|
||||||
PublishApplicationBeforeDeployment = true,
|
PublishApplicationBeforeDeployment = true,
|
||||||
TargetFramework = flavor == RuntimeFlavor.Clr ? "net461" : "netcoreapp2.0",
|
TargetFramework = flavor == RuntimeFlavor.Clr ? "net461" : "netcoreapp2.0",
|
||||||
Configuration = "Release",
|
Configuration = "Release",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
// 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.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Logging.Testing;
|
||||||
|
using Xunit;
|
||||||
|
using Xunit.Abstractions;
|
||||||
|
|
||||||
|
namespace FunctionalTests
|
||||||
|
{
|
||||||
|
public class PublishWithRidTest_CoreCLR : LoggedTest
|
||||||
|
{
|
||||||
|
public PublishWithRidTest_CoreCLR(ITestOutputHelper output)
|
||||||
|
: base(output)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void CrossPublishingWorks()
|
||||||
|
{
|
||||||
|
using (StartLog(out var loggerFactory))
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var applicationName = nameof(SimpleApp);
|
||||||
|
var applicationPath = ApplicationPaths.GetTestAppDirectory(applicationName);
|
||||||
|
var deploymentParameters = ApplicationTestFixture.GetDeploymentParameters(
|
||||||
|
applicationPath,
|
||||||
|
applicationName,
|
||||||
|
RuntimeFlavor.CoreClr);
|
||||||
|
|
||||||
|
// Deploy for a rid that does not exist on the current platform.
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
|
{
|
||||||
|
deploymentParameters.AdditionalPublishParameters = "-r debian-x64";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
deploymentParameters.AdditionalPublishParameters = "-r win7-x86";
|
||||||
|
}
|
||||||
|
var deployer = new DotNetPublishDeployer(deploymentParameters, loggerFactory);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
deployer.DotnetPublish();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var expectedFile = Path.Combine(
|
||||||
|
deploymentParameters.PublishedApplicationRootPath,
|
||||||
|
$"{applicationName}.PrecompiledViews.dll");
|
||||||
|
Assert.True(File.Exists(expectedFile), $"Expected precompiled file {expectedFile} does not exist.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DotNetPublishDeployer : ApplicationDeployer
|
||||||
|
{
|
||||||
|
public DotNetPublishDeployer(DeploymentParameters deploymentParameters, ILoggerFactory loggerFactory)
|
||||||
|
: base(deploymentParameters, loggerFactory)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DotnetPublish() => base.DotnetPublish();
|
||||||
|
|
||||||
|
public override void Dispose() => CleanPublishedOutput();
|
||||||
|
|
||||||
|
public override Task<DeploymentResult> DeployAsync() => throw new NotSupportedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue