diff --git a/makefile.shade b/makefile.shade
new file mode 100644
index 0000000000..f88fd7789d
--- /dev/null
+++ b/makefile.shade
@@ -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.
+ }
+ }
\ No newline at end of file
diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/CompilationOptions.cs b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/CompilationOptions.cs
index 5e7fc24f43..4adc9b3db7 100644
--- a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/CompilationOptions.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/CompilationOptions.cs
@@ -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";
diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/DebugHelper.cs b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/DebugHelper.cs
index 1999e85041..518b4318e6 100644
--- a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/DebugHelper.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/DebugHelper.cs
@@ -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)
{
diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/MvcServiceProvider.cs b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/MvcServiceProvider.cs
index fd26c58907..b2b63f2c6a 100644
--- a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/MvcServiceProvider.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/MvcServiceProvider.cs
@@ -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;
diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/PrecompilationApplication.cs b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/PrecompilationApplication.cs
index bd1ac8a803..4ba381b7f2 100644
--- a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/PrecompilationApplication.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/PrecompilationApplication.cs
@@ -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;
diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/PrecompileRunCommand.cs b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/PrecompileRunCommand.cs
index 8cda93e115..1dcb12f71f 100644
--- a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/PrecompileRunCommand.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/PrecompileRunCommand.cs
@@ -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
{
diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/SnkUtils.cs b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/SnkUtils.cs
index dfe3edb258..6e06878277 100644
--- a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/SnkUtils.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/SnkUtils.cs
@@ -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;
diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/ViewCompilationInfo.cs b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/ViewCompilationInfo.cs
index 8ab014365b..88e808670c 100644
--- a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/ViewCompilationInfo.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/ViewCompilationInfo.cs
@@ -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,
diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/ViewFileInfo.cs b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/ViewFileInfo.cs
index fe8f1196fc..56e0586525 100644
--- a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/ViewFileInfo.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/ViewFileInfo.cs
@@ -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)
{
diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/ViewInfoContainerCodeGenerator.cs b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/ViewInfoContainerCodeGenerator.cs
index c00ded2d08..52eee2242f 100644
--- a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/ViewInfoContainerCodeGenerator.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Internal/ViewInfoContainerCodeGenerator.cs
@@ -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,
diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.csproj b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.csproj
index 3c397e3d1d..fa704733cf 100644
--- a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.csproj
+++ b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.csproj
@@ -8,13 +8,11 @@
true
exe
..\..\pack\
-
- build
-
+
diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Program.cs b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Program.cs
index 623f661e3f..0b4b532c93 100644
--- a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Program.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Program.cs
@@ -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);
diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Properties/AssemblyInfo.cs
index 0715293428..313e1a2d31 100644
--- a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Properties/AssemblyInfo.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/Properties/AssemblyInfo.cs
@@ -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")]
+
diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/build/net451/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/build/net451/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets
index 032406f597..66a5c2b663 100644
--- a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/build/net451/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets
+++ b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/build/net451/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets
@@ -17,18 +17,12 @@
$(OutputPath)$(MSBuildThisFileName)-x86.exe.config
-
- $(OutputPath)$(MSBuildThisFileName)-x86.exe
-
$(OutputPath)$(MSBuildThisFileName).exe.config
-
- $(OutputPath)$(MSBuildThisFileName).exe
-
--runtimeconfig "$(ProjectRuntimeConfigFilePath)"
$(ExecArgs) --depsfile "$(ProjectDepsFilePath)"
- $(ExecArgs) "$(MSBuildThisFileDirectory)$(MSBuildThisFileName).dll"
+ $(ExecArgs) "$(MSBuildThisFileDirectory)../../lib/netcoreapp1.1/$(MSBuildThisFileName).dll"
$(ExecArgs) @"$(_MvcRazorResponseFilePath)"
diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests/Resources/SimpleAppMvc11Test.Home.Index.txt b/test/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests/Resources/SimpleAppMvc11Test.Home.Index.txt
new file mode 100644
index 0000000000..c963a4268b
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests/Resources/SimpleAppMvc11Test.Home.Index.txt
@@ -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
diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests/SimpleAppMvc11Test.cs b/test/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests/SimpleAppMvc11Test.cs
new file mode 100644
index 0000000000..0af5e7eb8d
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests/SimpleAppMvc11Test.cs
@@ -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
+ {
+ 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")
+ {
+ }
+ }
+ }
+}
diff --git a/testapps/SimpleAppMvc11/Controllers/HomeController.cs b/testapps/SimpleAppMvc11/Controllers/HomeController.cs
new file mode 100644
index 0000000000..0b44851019
--- /dev/null
+++ b/testapps/SimpleAppMvc11/Controllers/HomeController.cs
@@ -0,0 +1,9 @@
+using Microsoft.AspNetCore.Mvc;
+
+namespace SimpleApp.Controllers
+{
+ public class HomeController : Controller
+ {
+ public IActionResult Index() => View();
+ }
+}
diff --git a/testapps/SimpleAppMvc11/Program.cs b/testapps/SimpleAppMvc11/Program.cs
new file mode 100644
index 0000000000..6ed39c5e32
--- /dev/null
+++ b/testapps/SimpleAppMvc11/Program.cs
@@ -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()
+ .Build();
+
+ host.Run();
+ }
+ }
+}
diff --git a/testapps/SimpleAppMvc11/SimpleAppMvc11.csproj b/testapps/SimpleAppMvc11/SimpleAppMvc11.csproj
new file mode 100644
index 0000000000..ec241a12a9
--- /dev/null
+++ b/testapps/SimpleAppMvc11/SimpleAppMvc11.csproj
@@ -0,0 +1,22 @@
+
+
+ netcoreapp1.1;net451
+ true
+ Exe
+ win7-x64
+ true
+
+
+
+ 1.1.0-*
+ All
+
+
+
+
+
+
+
+
+
+
diff --git a/testapps/SimpleAppMvc11/Startup.cs b/testapps/SimpleAppMvc11/Startup.cs
new file mode 100644
index 0000000000..75bdc58008
--- /dev/null
+++ b/testapps/SimpleAppMvc11/Startup.cs
@@ -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();
+ }
+ }
+}
diff --git a/testapps/SimpleAppMvc11/Views/Home/Index.cshtml b/testapps/SimpleAppMvc11/Views/Home/Index.cshtml
new file mode 100644
index 0000000000..9807947451
--- /dev/null
+++ b/testapps/SimpleAppMvc11/Views/Home/Index.cshtml
@@ -0,0 +1 @@
+Hello from Index: @GetType().AssemblyQualifiedName
diff --git a/testapps/SimpleAppMvc11/Views/Shared/_Layout.cshtml b/testapps/SimpleAppMvc11/Views/Shared/_Layout.cshtml
new file mode 100644
index 0000000000..169bf3fca0
--- /dev/null
+++ b/testapps/SimpleAppMvc11/Views/Shared/_Layout.cshtml
@@ -0,0 +1,2 @@
+@RenderBody()
+@GetType().AssemblyQualifiedName
diff --git a/testapps/SimpleAppMvc11/Views/_ViewImports.cshtml b/testapps/SimpleAppMvc11/Views/_ViewImports.cshtml
new file mode 100644
index 0000000000..297d1ddb5c
--- /dev/null
+++ b/testapps/SimpleAppMvc11/Views/_ViewImports.cshtml
@@ -0,0 +1 @@
+@using SimpleApp
diff --git a/testapps/SimpleAppMvc11/Views/_ViewStart.cshtml b/testapps/SimpleAppMvc11/Views/_ViewStart.cshtml
new file mode 100644
index 0000000000..a5f10045db
--- /dev/null
+++ b/testapps/SimpleAppMvc11/Views/_ViewStart.cshtml
@@ -0,0 +1,3 @@
+@{
+ Layout = "_Layout";
+}