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'">
|
Condition="'$(MvcRazorCompileOnPublish)'=='true' AND '$(_MvcViewCompilationAddDesktopReferences)'!='false' AND '$(TargetFrameworkIdentifier)'=='.NETFramework'">
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(_MvcViewCompilationBinaryPath)'==''">
|
<PropertyGroup Condition="'$(_MvcViewCompilationBinaryPath)'==''">
|
||||||
<_MvcViewCompilationBinaryPath Condition="'$(PlatformTarget)'=='x64'">$(MSBuildThisFileDirectory)$(MSBuildThisFileName)-x64.exe</_MvcViewCompilationBinaryPath>
|
|
||||||
<_MvcViewCompilationBinaryPath Condition="'$(PlatformTarget)'=='x86'">$(MSBuildThisFileDirectory)$(MSBuildThisFileName)-x86.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>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(_MvcViewCompilationBinaryPath)'!=''">
|
<ItemGroup Condition="'$(_MvcViewCompilationBinaryPath)'!=''">
|
||||||
|
|
@ -99,18 +101,22 @@
|
||||||
DependsOnTargets="_AddDesktopReferences;_CreateResponseFileForMvcRazorPrecompile"
|
DependsOnTargets="_AddDesktopReferences;_CreateResponseFileForMvcRazorPrecompile"
|
||||||
Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework'">
|
Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework'">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<_MvcViewCompilationBinaryName>$([System.IO.Path]::GetFileName('$(_MvcViewCompilationBinaryPath)'))</_MvcViewCompilationBinaryName>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<_PreCompilationFilesToCopy
|
<_PreCompilationFilesToCopy
|
||||||
Include="$(OutputPath)$(AssemblyName).exe.config"
|
Include="$(OutputPath)$(AssemblyName).exe.config"
|
||||||
Destination="$(OutputPath)$(MSBuildThisFileName)-$(PlatformTarget).exe.config" />
|
Destination="$(OutputPath)$(_MvcViewCompilationBinaryName).config" />
|
||||||
|
|
||||||
<_PreCompilationFilesToCopy
|
<_PreCompilationFilesToCopy
|
||||||
Include="$(_MvcViewCompilationBinaryPath)"
|
Include="$(_MvcViewCompilationBinaryPath)"
|
||||||
Destination="$(OutputPath)$(MSBuildThisFileName)-$(PlatformTarget).exe" />
|
Destination="$(OutputPath)$(_MvcViewCompilationBinaryName)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(MvcRazorRunCommand)'==''">
|
<PropertyGroup Condition="'$(MvcRazorRunCommand)'==''">
|
||||||
<MvcRazorRunCommand>$(OutputPath)$(MSBuildThisFileName)-$(PlatformTarget).exe</MvcRazorRunCommand>
|
<MvcRazorRunCommand>$(OutputPath)$(_MvcViewCompilationBinaryName)</MvcRazorRunCommand>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Copy
|
<Copy
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ namespace FunctionalTests
|
||||||
public ApplicationTestFixture Fixture { get; }
|
public ApplicationTestFixture Fixture { get; }
|
||||||
|
|
||||||
[ConditionalFact]
|
[ConditionalFact]
|
||||||
[Fact]
|
|
||||||
public async Task PublishingInDebugWorks()
|
public async Task PublishingInDebugWorks()
|
||||||
{
|
{
|
||||||
using (StartLog(out var loggerFactory))
|
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()
|
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">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks>
|
||||||
<TargetFrameworks Condition="'$(DeveloperBuild)'!='true'">$(TargetFrameworks);netcoreapp2.0</TargetFrameworks>
|
|
||||||
|
|
||||||
<DefineConstants>$(DefineConstants);__remove_this_to__GENERATE_BASELINES</DefineConstants>
|
<DefineConstants>$(DefineConstants);__remove_this_to__GENERATE_BASELINES</DefineConstants>
|
||||||
<DefineConstants Condition="'$(GenerateBaseLines)'=='true'">$(DefineConstants);GENERATE_BASELINES</DefineConstants>
|
<DefineConstants Condition="'$(GenerateBaseLines)'=='true'">$(DefineConstants);GENERATE_BASELINES</DefineConstants>
|
||||||
|
|
@ -33,7 +32,6 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\testapps\ApplicationUsingPrecompiledViewClassLibrary\ApplicationUsingPrecompiledViewClassLibrary.csproj" />
|
|
||||||
<ProjectReference Include="..\..\testapps\ApplicationUsingRelativePaths\ApplicationUsingRelativePaths.csproj" />
|
<ProjectReference Include="..\..\testapps\ApplicationUsingRelativePaths\ApplicationUsingRelativePaths.csproj" />
|
||||||
<ProjectReference Include="..\..\testapps\ApplicationWithConfigureMvc\ApplicationWithConfigureMvc.csproj" />
|
<ProjectReference Include="..\..\testapps\ApplicationWithConfigureMvc\ApplicationWithConfigureMvc.csproj" />
|
||||||
<ProjectReference Include="..\..\testapps\ApplicationWithCustomInputFiles\ApplicationWithCustomInputFiles.csproj" />
|
<ProjectReference Include="..\..\testapps\ApplicationWithCustomInputFiles\ApplicationWithCustomInputFiles.csproj" />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue