Use x64 binaries when project's targeting AnyCPU (#255)
* Use x64 binaries when project's targeting AnyCPU Fixes https://github.com/aspnet/MvcPrecompilation/issues/240
This commit is contained in:
parent
1338f447fa
commit
ad724f6b0a
|
|
@ -85,8 +85,10 @@
|
|||
Condition="'$(MvcRazorCompileOnPublish)'=='true' AND '$(_MvcViewCompilationAddDesktopReferences)'!='false' AND '$(TargetFrameworkIdentifier)'=='.NETFramework'">
|
||||
|
||||
<PropertyGroup Condition="'$(_MvcViewCompilationBinaryPath)'==''">
|
||||
<_MvcViewCompilationBinaryPath Condition="'$(PlatformTarget)'=='x64'">$(MSBuildThisFileDirectory)$(MSBuildThisFileName)-x64.exe</_MvcViewCompilationBinaryPath>
|
||||
<_MvcViewCompilationBinaryPath Condition="'$(PlatformTarget)'=='x86'">$(MSBuildThisFileDirectory)$(MSBuildThisFileName)-x86.exe</_MvcViewCompilationBinaryPath>
|
||||
|
||||
<!-- For PlatformTarget = AnyCPU or x64, we will use the x64 binary -->
|
||||
<_MvcViewCompilationBinaryPath Condition="'$(_MvcViewCompilationBinaryPath)'==''">$(MSBuildThisFileDirectory)$(MSBuildThisFileName)-x64.exe</_MvcViewCompilationBinaryPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(_MvcViewCompilationBinaryPath)'!=''">
|
||||
|
|
@ -99,18 +101,22 @@
|
|||
DependsOnTargets="_AddDesktopReferences;_CreateResponseFileForMvcRazorPrecompile"
|
||||
Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework'">
|
||||
|
||||
<PropertyGroup>
|
||||
<_MvcViewCompilationBinaryName>$([System.IO.Path]::GetFileName('$(_MvcViewCompilationBinaryPath)'))</_MvcViewCompilationBinaryName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<_PreCompilationFilesToCopy
|
||||
Include="$(OutputPath)$(AssemblyName).exe.config"
|
||||
Destination="$(OutputPath)$(MSBuildThisFileName)-$(PlatformTarget).exe.config" />
|
||||
Destination="$(OutputPath)$(_MvcViewCompilationBinaryName).config" />
|
||||
|
||||
<_PreCompilationFilesToCopy
|
||||
Include="$(_MvcViewCompilationBinaryPath)"
|
||||
Destination="$(OutputPath)$(MSBuildThisFileName)-$(PlatformTarget).exe" />
|
||||
Destination="$(OutputPath)$(_MvcViewCompilationBinaryName)" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(MvcRazorRunCommand)'==''">
|
||||
<MvcRazorRunCommand>$(OutputPath)$(MSBuildThisFileName)-$(PlatformTarget).exe</MvcRazorRunCommand>
|
||||
<MvcRazorRunCommand>$(OutputPath)$(_MvcViewCompilationBinaryName)</MvcRazorRunCommand>
|
||||
</PropertyGroup>
|
||||
|
||||
<Copy
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ namespace FunctionalTests
|
|||
public ApplicationTestFixture Fixture { get; }
|
||||
|
||||
[ConditionalFact]
|
||||
[Fact]
|
||||
public async Task PublishingInDebugWorks()
|
||||
{
|
||||
using (StartLog(out var loggerFactory))
|
||||
|
|
@ -41,7 +40,7 @@ namespace FunctionalTests
|
|||
}
|
||||
}
|
||||
|
||||
public class TestFixture : CoreCLRApplicationTestFixture<SimpleApp.Startup>
|
||||
public class TestFixture : DesktopApplicationTestFixture<SimpleApp.Startup>
|
||||
{
|
||||
public TestFixture()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
// 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.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 | OperatingSystems.MacOSX)]
|
||||
public class SimpleAppTest_WithAnyCPU_Desktop :
|
||||
LoggedTest, IClassFixture<SimpleAppTest_WithAnyCPU_Desktop.TestFixture>
|
||||
{
|
||||
public SimpleAppTest_WithAnyCPU_Desktop(
|
||||
TestFixture fixture,
|
||||
ITestOutputHelper output)
|
||||
: base(output)
|
||||
{
|
||||
Fixture = fixture;
|
||||
}
|
||||
|
||||
public ApplicationTestFixture Fixture { get; }
|
||||
|
||||
[ConditionalFact]
|
||||
public async Task Precompilation_WorksForSimpleApps_BuiltWithPlatformTargetAnyCPU()
|
||||
{
|
||||
using (StartLog(out var loggerFactory))
|
||||
{
|
||||
// Arrange
|
||||
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
|
||||
|
||||
// Act & Assert
|
||||
var dllFile = Path.Combine(deployment.ContentRoot, "SimpleApp.PrecompiledViews.dll");
|
||||
Assert.True(File.Exists(dllFile), $"{dllFile} exists at deployment.");
|
||||
}
|
||||
}
|
||||
|
||||
public class TestFixture : DesktopApplicationTestFixture<SimpleApp.Startup>
|
||||
{
|
||||
public TestFixture()
|
||||
{
|
||||
PublishOnly = true;
|
||||
}
|
||||
|
||||
protected override DeploymentParameters GetDeploymentParameters()
|
||||
{
|
||||
var deploymentParameters = base.GetDeploymentParameters();
|
||||
deploymentParameters.AdditionalPublishParameters = "/p:PlatformTarget=AnyCPU";
|
||||
|
||||
return deploymentParameters;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
||||
<TargetFrameworks Condition="'$(DeveloperBuild)'!='true'">$(TargetFrameworks);netcoreapp2.0</TargetFrameworks>
|
||||
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks>
|
||||
|
||||
<DefineConstants>$(DefineConstants);__remove_this_to__GENERATE_BASELINES</DefineConstants>
|
||||
<DefineConstants Condition="'$(GenerateBaseLines)'=='true'">$(DefineConstants);GENERATE_BASELINES</DefineConstants>
|
||||
|
|
@ -33,7 +32,6 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\testapps\ApplicationUsingPrecompiledViewClassLibrary\ApplicationUsingPrecompiledViewClassLibrary.csproj" />
|
||||
<ProjectReference Include="..\..\testapps\ApplicationUsingRelativePaths\ApplicationUsingRelativePaths.csproj" />
|
||||
<ProjectReference Include="..\..\testapps\ApplicationWithConfigureMvc\ApplicationWithConfigureMvc.csproj" />
|
||||
<ProjectReference Include="..\..\testapps\ApplicationWithCustomInputFiles\ApplicationWithCustomInputFiles.csproj" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue