ViewCompilation 1.1.0-msbuild3-final does not work with Microsoft.AspNetCore.Mvc 1.1.1
Fixes #78
This commit is contained in:
parent
2276c9eafe
commit
57e7f35fab
|
|
@ -0,0 +1,51 @@
|
|||
use namespace="System.IO"
|
||||
use namespace="System.IO.Compression"
|
||||
use namespace="System.Linq"
|
||||
|
||||
use-standard-lifecycle
|
||||
k-standard-goals
|
||||
|
||||
#repack-x86 target='compile' if='Directory.Exists("src")'
|
||||
@{
|
||||
var buildDir= Path.Combine(Directory.GetCurrentDirectory(), "artifacts", "build");
|
||||
var projectName = "Microsoft.AspNetCore.Mvc.Razor.ViewCompilation";
|
||||
var projectNupkg = Files
|
||||
.Include(Path.Combine(buildDir, projectName + "*.nupkg"))
|
||||
.Where(path => !path.EndsWith(".symbols.nupkg", StringComparison.OrdinalIgnoreCase))
|
||||
.OrderByDescending(f => f) // On local builds multiple nupkgs are generated.
|
||||
.First();
|
||||
|
||||
Log.Info("Repacking Nupkg: " + projectNupkg);
|
||||
|
||||
var extractToDirectory = projectNupkg + "-temp";
|
||||
ZipFile.ExtractToDirectory(projectNupkg, extractToDirectory);
|
||||
|
||||
var runtimesDirectory = Path.Combine(extractToDirectory, "runtimes");
|
||||
var win7x86Directory = Path.Combine(runtimesDirectory, "win7-x86", "lib", "net451");
|
||||
var win7x64Directory = Path.Combine(runtimesDirectory, "win7-x64", "lib", "net451");
|
||||
Directory.CreateDirectory(win7x86Directory);
|
||||
Directory.CreateDirectory(win7x64Directory);
|
||||
var net451LibDirectory = Path.Combine(extractToDirectory, "lib", "net451");
|
||||
|
||||
File.Move(
|
||||
Path.Combine(net451LibDirectory, projectName + ".exe"),
|
||||
Path.Combine(win7x64Directory, projectName + ".exe"));
|
||||
File.Move(
|
||||
Path.Combine(net451LibDirectory, projectName + "-x86.exe"),
|
||||
Path.Combine(win7x86Directory, projectName + "-x86.exe"));
|
||||
|
||||
File.WriteAllBytes(Path.Combine(net451LibDirectory, "_._"), new byte[0]);
|
||||
|
||||
File.Delete(projectNupkg);
|
||||
ZipFile.CreateFromDirectory(extractToDirectory, projectNupkg);
|
||||
|
||||
try
|
||||
{
|
||||
// Delete temporary directory we used to repack.
|
||||
Directory.Delete(extractToDirectory, true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Don't care if we couldn't delete the temp directory.
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ using Microsoft.Extensions.CommandLineUtils;
|
|||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||
{
|
||||
public class CompilationOptions
|
||||
internal class CompilationOptions
|
||||
{
|
||||
public static readonly string ConfigureCompilationTypeTemplate = "--configure-compilation-type";
|
||||
public static readonly string ContentRootTemplate = "--content-root";
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using System.Linq;
|
|||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||
{
|
||||
public static class DebugHelper
|
||||
internal static class DebugHelper
|
||||
{
|
||||
public static void HandleDebugSwitch(ref string[] args)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ using Microsoft.Extensions.Options;
|
|||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||
{
|
||||
public class MvcServiceProvider
|
||||
internal class MvcServiceProvider
|
||||
{
|
||||
private readonly string _projectPath;
|
||||
private readonly string _contentRoot;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ using Microsoft.Extensions.CommandLineUtils;
|
|||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||
{
|
||||
public class PrecompilationApplication : CommandLineApplication
|
||||
internal class PrecompilationApplication : CommandLineApplication
|
||||
{
|
||||
private readonly Type _callingType;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ using Microsoft.Extensions.CommandLineUtils;
|
|||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||
{
|
||||
public class PrecompileRunCommand
|
||||
internal class PrecompileRunCommand
|
||||
{
|
||||
private static readonly ParallelOptions ParalellOptions = new ParallelOptions
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using System.IO;
|
|||
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||
{
|
||||
// Copied from https://github.com/dotnet/cli/blob/rel/1.0.0/src/Microsoft.DotNet.ProjectModel.Workspaces/SnkUtils.cs
|
||||
public static class SnkUtils
|
||||
internal static class SnkUtils
|
||||
{
|
||||
const byte PUBLICKEYBLOB = 0x06;
|
||||
const byte PRIVATEKEYBLOB = 0x07;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Razor.CodeGenerators;
|
|||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||
{
|
||||
public class ViewCompilationInfo
|
||||
internal class ViewCompilationInfo
|
||||
{
|
||||
public ViewCompilationInfo(
|
||||
ViewFileInfo viewFileInfo,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using System.IO;
|
|||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||
{
|
||||
public struct ViewFileInfo
|
||||
internal struct ViewFileInfo
|
||||
{
|
||||
public ViewFileInfo(string fullPath, string viewEnginePath)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ using Microsoft.CodeAnalysis.Text;
|
|||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||
{
|
||||
public class ViewInfoContainerCodeGenerator
|
||||
internal class ViewInfoContainerCodeGenerator
|
||||
{
|
||||
public ViewInfoContainerCodeGenerator(
|
||||
CSharpCompiler compiler,
|
||||
|
|
|
|||
|
|
@ -8,13 +8,11 @@
|
|||
<PreserveCompilationContext>true</PreserveCompilationContext>
|
||||
<OutputType>exe</OutputType>
|
||||
<X86ProjectDirectory>..\..\pack\</X86ProjectDirectory>
|
||||
<!-- Include the build outputs in the build directory (and not the lib directory) -->
|
||||
<BuildOutputTargetFolder>build</BuildOutputTargetFolder>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="build\**\*" Pack="true" PackagePath="%(Identity)" />
|
||||
<None Include="buildMultiTargeting/*" Pack="true" PackagePath="%(Identity)" />
|
||||
<None Include="$(X86ProjectDirectory)\bin\$(Configuration)\net451\$(MSBuildThisFileName)-x86.exe" Pack="true" PackagePath="build\net451\$(MSBuildThisFileName)-x86.exe" />
|
||||
<None Include="$(X86ProjectDirectory)\bin\$(Configuration)\net451\$(MSBuildThisFileName)-x86.exe" Pack="true" PackagePath="lib\net451\$(MSBuildThisFileName)-x86.exe" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="1.1.0" />
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal;
|
|||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||
{
|
||||
public class Program
|
||||
internal class Program
|
||||
{
|
||||
private readonly static Type ProgramType = typeof(Program);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
// 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.Runtime.CompilerServices;
|
||||
|
||||
[assembly: System.Reflection.AssemblyMetadata("Serviceable", "True")]
|
||||
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
||||
|
||||
|
|
|
|||
|
|
@ -17,18 +17,12 @@
|
|||
<FilesToCopy Include="$(OutputPath)$(AssemblyName).exe.config">
|
||||
<Destination>$(OutputPath)$(MSBuildThisFileName)-x86.exe.config</Destination>
|
||||
</FilesToCopy>
|
||||
<FilesToCopy Include="$(MSBuildThisFileDirectory)$(MSBuildThisFileName)-x86.exe">
|
||||
<Destination>$(OutputPath)$(MSBuildThisFileName)-x86.exe</Destination>
|
||||
</FilesToCopy>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(PlatformTarget)'!='x86'">
|
||||
<FilesToCopy Include="$(OutputPath)$(AssemblyName).exe.config" Condition="">
|
||||
<Destination>$(OutputPath)$(MSBuildThisFileName).exe.config</Destination>
|
||||
</FilesToCopy>
|
||||
<FilesToCopy Include="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).exe">
|
||||
<Destination>$(OutputPath)$(MSBuildThisFileName).exe</Destination>
|
||||
</FilesToCopy>
|
||||
</ItemGroup>
|
||||
|
||||
<Copy
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
<PropertyGroup>
|
||||
<ExecArgs>--runtimeconfig "$(ProjectRuntimeConfigFilePath)"</ExecArgs>
|
||||
<ExecArgs>$(ExecArgs) --depsfile "$(ProjectDepsFilePath)"</ExecArgs>
|
||||
<ExecArgs>$(ExecArgs) "$(MSBuildThisFileDirectory)$(MSBuildThisFileName).dll"</ExecArgs>
|
||||
<ExecArgs>$(ExecArgs) "$(MSBuildThisFileDirectory)../../lib/netcoreapp1.1/$(MSBuildThisFileName).dll"</ExecArgs>
|
||||
<ExecArgs>$(ExecArgs) @"$(_MvcRazorResponseFilePath)"</ExecArgs>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
Hello from Index: AspNetCore._Views_Home_Index_cshtml, SimpleAppMvc11.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
|
||||
AspNetCore._Views_Shared__Layout_cshtml, SimpleAppMvc11.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
// 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.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||
{
|
||||
public class SimpleAppMvc11Test : IClassFixture<SimpleAppMvc11Test.TestFixture>
|
||||
{
|
||||
public SimpleAppMvc11Test(TestFixture fixture)
|
||||
{
|
||||
Fixture = fixture;
|
||||
}
|
||||
|
||||
public ApplicationTestFixture Fixture { get; }
|
||||
|
||||
public static TheoryData SupportedFlavorsTheoryData => RuntimeFlavors.SupportedFlavorsTheoryData;
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||
public async Task Precompilation_WorksWithsAppsTargetingHigherVersionOfMvc(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
using (var deployer = Fixture.CreateDeployment(flavor))
|
||||
{
|
||||
var deploymentResult = deployer.Deploy();
|
||||
|
||||
// Act
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
deploymentResult.ApplicationBaseUri,
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("SimpleAppMvc11Test.Home.Index.txt", response);
|
||||
}
|
||||
}
|
||||
|
||||
public class TestFixture : ApplicationTestFixture
|
||||
{
|
||||
public TestFixture()
|
||||
: base("SimpleAppMvc11")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace SimpleApp.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
public IActionResult Index() => View();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
using System.IO;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace SimpleApp
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var config = new ConfigurationBuilder()
|
||||
.AddCommandLine(args)
|
||||
.AddEnvironmentVariables(prefix: "ASPNETCORE_")
|
||||
.Build();
|
||||
|
||||
var host = new WebHostBuilder()
|
||||
.UseConfiguration(config)
|
||||
.UseKestrel()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
|
||||
host.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web" ToolsVersion="15.0">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp1.1;net451</TargetFrameworks>
|
||||
<PreserveCompilationContext>true</PreserveCompilationContext>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RuntimeIdentifier Condition="!$(TargetFramework.StartsWith('netcoreapp'))">win7-x64</RuntimeIdentifier>
|
||||
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation">
|
||||
<Version>1.1.0-*</Version>
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="1.1.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">
|
||||
<PackageReference Include="Microsoft.NETCore.App" Version="1.1.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace SimpleApp
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddMvc();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
||||
{
|
||||
loggerFactory.AddConsole();
|
||||
app.UseMvcWithDefaultRoute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
Hello from Index: @GetType().AssemblyQualifiedName
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
@RenderBody()
|
||||
@GetType().AssemblyQualifiedName
|
||||
|
|
@ -0,0 +1 @@
|
|||
@using SimpleApp
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
Loading…
Reference in New Issue