diff --git a/src/MvcPrecompilation/build/dependencies.props b/src/MvcPrecompilation/build/dependencies.props index 73061aad9f..e58a89000f 100644 --- a/src/MvcPrecompilation/build/dependencies.props +++ b/src/MvcPrecompilation/build/dependencies.props @@ -3,31 +3,31 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180928.5 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 0.6.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 + 3.0.0-alpha1-20180821.3 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 0.7.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 15.6.82 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 2.0.9 - 2.1.3 - 2.2.0-preview3-26927-02 - 2.2.0-preview3-35359 + 2.1.2 + 2.2.0-preview1-26618-02 + 3.0.0-alpha1-10352 15.6.1 2.0.3 2.3.1 2.4.0 - + diff --git a/src/MvcPrecompilation/build/repo.props b/src/MvcPrecompilation/build/repo.props index f1fe24dd27..17a98ac7e7 100644 --- a/src/MvcPrecompilation/build/repo.props +++ b/src/MvcPrecompilation/build/repo.props @@ -4,7 +4,6 @@ Internal.AspNetCore.Universe.Lineup - 2.2.0-* https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json diff --git a/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/ApplicationWithConfigureMvcTest_CoreCLR.cs b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/ApplicationWithConfigureMvcTest_CoreCLR.cs new file mode 100644 index 0000000000..0916f7af1e --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/ApplicationWithConfigureMvcTest_CoreCLR.cs @@ -0,0 +1,62 @@ +// 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.Threading.Tasks; +using Microsoft.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + public class ApplicationWithConfigureMvcTest_CoreCLR + : LoggedTest, IClassFixture> + { + public ApplicationWithConfigureMvcTest_CoreCLR( + CoreCLRApplicationTestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [Fact] + public async Task Precompilation_RunsConfiguredCompilationCallbacks() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + deployment.ApplicationBaseUri, + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent("ApplicationWithConfigureMvc.Home.Index.txt", response); + } + } + + [Fact] + public async Task Precompilation_UsesConfiguredParseOptions() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + "Home/ViewWithPreprocessor", + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent( + "ApplicationWithConfigureMvc.Home.ViewWithPreprocessor.txt", + response); + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/ApplicationWithCustomInputFilesTest_CoreCLR.cs b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/ApplicationWithCustomInputFilesTest_CoreCLR.cs new file mode 100644 index 0000000000..bce4f0a260 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/ApplicationWithCustomInputFilesTest_CoreCLR.cs @@ -0,0 +1,105 @@ +// 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.Linq; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + public class ApplicationWithCustomInputFilesTest_CoreCLR + : LoggedTest, IClassFixture> + { + public ApplicationWithCustomInputFilesTest_CoreCLR( + CoreCLRApplicationTestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [Fact] + public async Task ApplicationWithCustomInputFiles_Works() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + var expectedText = "Hello Index!"; + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + deployment.ApplicationBaseUri, + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + Assert.Equal(expectedText, response.Trim()); + } + } + + [Fact] + public async Task MvcRazorFilesToCompile_OverridesTheFilesToBeCompiled() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + var expectedViews = new[] + { + "/Views/Home/About.cshtml", + "/Views/Home/Index.cshtml", + }; + + // Act + var response2 = await deployment.HttpClient.GetStringWithRetryAsync( + "Home/GetPrecompiledResourceNames", + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + var actual = response2.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries) + .OrderBy(p => p, StringComparer.OrdinalIgnoreCase); + Assert.Equal(expectedViews, actual); + } + } + + [Fact] + public async Task MvcRazorFilesToCompile_SpecificallyDoesNotPublishFilesToBeCompiled() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + var viewsNotPublished = new[] + { + "Index.cshtml", + "About.cshtml", + }; + + var viewsPublished = new[] + { + "NotIncluded.cshtml", + }; + var viewsDirectory = Path.Combine(deployment.ContentRoot, "Views", "Home"); + + // Act & Assert + foreach (var file in viewsPublished) + { + var filePath = Path.Combine(viewsDirectory, file); + Assert.True(File.Exists(filePath), $"{filePath} was not published."); + } + + foreach (var file in viewsNotPublished) + { + var filePath = Path.Combine(viewsDirectory, file); + Assert.False(File.Exists(filePath), $"{filePath} was published."); + } + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/ApplicationWithParseErrorsTest_CoreCLR.cs b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/ApplicationWithParseErrorsTest_CoreCLR.cs new file mode 100644 index 0000000000..ce66f29457 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/ApplicationWithParseErrorsTest_CoreCLR.cs @@ -0,0 +1,49 @@ +// 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.Linq; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging.Testing; +using Xunit; + +namespace FunctionalTests +{ + public class ApplicationWithParseErrorsTest_CoreCLR + : IClassFixture> + { + public ApplicationWithParseErrorsTest_CoreCLR(CoreCLRApplicationTestFixture fixture) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [Fact(Skip = "Flaky test in many build configurations. See issue #277.")] + public async Task PublishingPrintsParseErrors() + { + // Arrange + var indexPath = Path.Combine(Fixture.TestProjectDirectory, "Views", "Home", "Index.cshtml"); + var viewImportsPath = Path.Combine(Fixture.TestProjectDirectory, "Views", "Home", "About.cshtml"); + var expectedErrors = new[] + { + indexPath + " (0): The code block is missing a closing \"}\" character. Make sure you have a matching \"}\" character for all the \"{\" characters within this block, and that none of the \"}\" characters are being interpreted as markup.", + viewImportsPath + " (1): A space or line break was encountered after the \"@\" character. Only valid identifiers, keywords, comments, \"(\" and \"{\" are valid at the start of a code block and they must occur immediately following \"@\" with no space in between.", + + }; + var testSink = new TestSink(); + var loggerFactory = new TestLoggerFactory(testSink, enabled: true); + + // Act + await Assert.ThrowsAsync(() => Fixture.CreateDeploymentAsync(loggerFactory)); + + // Assert + var logs = testSink.Writes.Select(w => w.State.ToString().Trim()).ToList(); + foreach (var expectedError in expectedErrors) + { + Assert.Contains(logs, log => log.Contains(expectedError)); + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/ApplicationWithTagHelpersTest_CoreCLR.cs b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/ApplicationWithTagHelpersTest_CoreCLR.cs new file mode 100644 index 0000000000..3f42c7c1c7 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/ApplicationWithTagHelpersTest_CoreCLR.cs @@ -0,0 +1,75 @@ +// 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.Extensions.Logging; +using Microsoft.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + public class ApplicationWithTagHelpersTest_CoreCLR : + LoggedTest, IClassFixture + { + public ApplicationWithTagHelpersTest_CoreCLR( + ApplicationWithTagHelpersTestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [Fact] + public async Task Precompilation_WorksForViewsThatUseTagHelpersFromProjectReferences() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + "Home/ClassLibraryTagHelper", + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent($"ApplicationWithTagHelpers.Home.ClassLibraryTagHelper.txt", response); + } + } + + [Fact] + public async Task Precompilation_WorksForViewsThatUseTagHelpersFromCurrentProject() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + "Home/LocalTagHelper", + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent($"ApplicationWithTagHelpers.Home.LocalTagHelper.txt", response); + } + } + + public class ApplicationWithTagHelpersTestFixture : CoreCLRApplicationTestFixture + { + protected override Task CreateDeploymentAsyncCore(ILoggerFactory loggerFactory) + { + CopyDirectory( + new DirectoryInfo(Path.Combine(ApplicationPath, "..", "ClassLibraryTagHelper")), + new DirectoryInfo(Path.Combine(WorkingDirectory, "ClassLibraryTagHelper"))); + + return base.CreateDeploymentAsyncCore(loggerFactory); + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/PublishWithEmbedViewSourcesTest_CoreCLR.cs b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/PublishWithEmbedViewSourcesTest_CoreCLR.cs new file mode 100644 index 0000000000..b6a3e54ae7 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/PublishWithEmbedViewSourcesTest_CoreCLR.cs @@ -0,0 +1,62 @@ +// 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.Linq; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + public class PublishWithEmbedViewSourcesTest_CoreCLR + : LoggedTest, IClassFixture> + { + public PublishWithEmbedViewSourcesTest_CoreCLR( + CoreCLRApplicationTestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [Fact] + public async Task Precompilation_CanEmbedViewSourcesAsResources() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + var logger = loggerFactory.CreateLogger(Fixture.ApplicationName); + var expectedViews = new[] + { + "/Areas/TestArea/Views/Home/Index.cshtml", + "/Views/Home/About.cshtml", + "/Views/Home/Index.cshtml", + }; + var expectedText = "Hello Index!"; + + // Act - 1 + var response1 = await deployment.HttpClient.GetStringWithRetryAsync( + "Home/Index", + logger); + + // Assert - 1 + Assert.Equal(expectedText, response1.Trim()); + + // Act - 2 + var response2 = await deployment.HttpClient.GetStringWithRetryAsync( + "Home/GetPrecompiledResourceNames", + logger); + + // Assert - 2 + var actual = response2.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries) + .OrderBy(p => p, StringComparer.OrdinalIgnoreCase); + Assert.Equal(expectedViews, actual); + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/RazorPagesAppTest_CoreCLR.cs b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/RazorPagesAppTest_CoreCLR.cs new file mode 100644 index 0000000000..9c9a107cb8 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/RazorPagesAppTest_CoreCLR.cs @@ -0,0 +1,134 @@ +// 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.Threading.Tasks; +using Microsoft.AspNetCore.Server.IntegrationTesting; +using Microsoft.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + public class RazorPagesAppTest_CoreCLR : + LoggedTest, IClassFixture> + { + public RazorPagesAppTest_CoreCLR( + CoreCLRApplicationTestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [Fact(Skip = "https://github.com/aspnet/MvcPrecompilation/issues/287")] + public async Task Precompilation_WorksForIndexPage_UsingFolderName() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + "/", + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent("RazorPages.Index.txt", response); + } + } + + [Fact(Skip = "https://github.com/aspnet/MvcPrecompilation/issues/287")] + public async Task Precompilation_WorksForIndexPage_UsingFileName() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + "/Index", + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent("RazorPages.Index.txt", response); + } + } + + [Fact(Skip = "https://github.com/aspnet/MvcPrecompilation/issues/287")] + public async Task Precompilation_WorksForPageWithModel() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + "/PageWithModel?person=Dan", + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent("RazorPages.PageWithModel.txt", response); + } + } + + [Fact(Skip = "https://github.com/aspnet/MvcPrecompilation/issues/287")] + public async Task Precompilation_WorksForPageWithRoute() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + "/PageWithRoute/Dan", + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent("RazorPages.PageWithRoute.txt", response); + } + } + + [Fact(Skip = "https://github.com/aspnet/MvcPrecompilation/issues/287")] + public async Task Precompilation_WorksForPageInNestedFolder() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + "/Nested1/Nested2/PageWithTagHelper", + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent("RazorPages.Nested1.Nested2.PageWithTagHelper.txt", response); + } + } + + [Fact(Skip = "https://github.com/aspnet/MvcPrecompilation/issues/287")] + public async Task Precompilation_WorksWithPageConventions() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await RetryHelper.RetryRequest( + () => deployment.HttpClient.GetAsync("/Auth/Index"), + loggerFactory.CreateLogger(Fixture.ApplicationName), + retryCount: 5); + + // Assert + Assert.Equal("/Login?ReturnUrl=%2FAuth%2FIndex", response.RequestMessage.RequestUri.PathAndQuery); + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/RazorSdkNeitherUsedTest_CoreCLR.cs b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/RazorSdkNeitherUsedTest_CoreCLR.cs new file mode 100644 index 0000000000..faea04ab38 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/RazorSdkNeitherUsedTest_CoreCLR.cs @@ -0,0 +1,46 @@ +// 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.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + // Tests that cover cases where both Razor SDK and MvcPrecompilation are installed. This is the default in 2.1 + public class RazorSdkNeitherUsedTest_CoreCLR : LoggedTest, IClassFixture> + { + public RazorSdkNeitherUsedTest_CoreCLR( + CoreCLRApplicationTestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [Fact] + public async Task Publish_HasNoPrecompilation() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await RetryHelper.RetryRequest( + () => deployment.HttpClient.GetAsync(deployment.ApplicationBaseUri), + loggerFactory.CreateLogger(Fixture.ApplicationName), + retryCount: 5); + + // Assert + Assert.False(File.Exists(Path.Combine(deployment.ContentRoot, "ApplicationWithRazorSdkNeitherUsed.PrecompiledViews.dll"))); + Assert.False(File.Exists(Path.Combine(deployment.ContentRoot, "ApplicationWithRazorSdkNeitherUsed.Views.dll"))); + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/RazorSdkPrecompilationUsedTest_CoreCLR.cs b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/RazorSdkPrecompilationUsedTest_CoreCLR.cs new file mode 100644 index 0000000000..130553d855 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/RazorSdkPrecompilationUsedTest_CoreCLR.cs @@ -0,0 +1,45 @@ +// 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.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + // Tests that cover cases where both Razor SDK and MvcPrecompilation are installed. This is the default in 2.1 + public class RazorSdkPrecompilationUsedTest_CoreCLR : LoggedTest, IClassFixture> + { + public RazorSdkPrecompilationUsedTest_CoreCLR( + CoreCLRApplicationTestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [Fact] + public async Task Publish_UsesRazorSDK() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + deployment.ApplicationBaseUri, + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + Assert.True(File.Exists(Path.Combine(deployment.ContentRoot, "ApplicationWithRazorSdkPrecompilationUsed.PrecompiledViews.dll"))); + Assert.False(File.Exists(Path.Combine(deployment.ContentRoot, "ApplicationWithRazorSdkPrecompilationUsed.Views.dll"))); + TestEmbeddedResource.AssertContent("ApplicationWithRazorSdkPrecompilationUsed.Home.Index.txt", response); + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/RazorSdkUsedTest_CoreCLR.cs b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/RazorSdkUsedTest_CoreCLR.cs new file mode 100644 index 0000000000..6f1a4ff918 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/RazorSdkUsedTest_CoreCLR.cs @@ -0,0 +1,47 @@ +// 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.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + // Tests that cover cases where both Razor SDK and MvcPrecompilation are installed. This is the default in 2.1 + public class RazorSdkUsedTest_CoreCLR : LoggedTest, IClassFixture> + { + public RazorSdkUsedTest_CoreCLR( + CoreCLRApplicationTestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [Fact] + public async Task Publish_UsesRazorSDK() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + var expectedViewLocation = Path.Combine(deployment.ContentRoot, "ApplicationWithRazorSdkUsed.Views.dll"); + var expectedPrecompiledViewsLocation = Path.Combine(deployment.ContentRoot, "ApplicationWithRazorSdkUsed.PrecompiledViews.dll"); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + deployment.ApplicationBaseUri, + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + Assert.False(File.Exists(expectedPrecompiledViewsLocation), $"{expectedPrecompiledViewsLocation} existed, but shouldn't have."); + Assert.True(File.Exists(expectedViewLocation), $"{expectedViewLocation} didn't exist."); + TestEmbeddedResource.AssertContent("ApplicationWithRazorSdkUsed.Home.Index.txt", response); + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/SimpleAppWithAssemblyRenameTest_CoreCLR.cs b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/SimpleAppWithAssemblyRenameTest_CoreCLR.cs new file mode 100644 index 0000000000..dddd8cf097 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/SimpleAppWithAssemblyRenameTest_CoreCLR.cs @@ -0,0 +1,52 @@ +// 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.Threading.Tasks; +using Microsoft.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + public class SimpleAppWithAssemblyRenameTest_CoreCLR : + LoggedTest, IClassFixture + { + public SimpleAppWithAssemblyRenameTest_CoreCLR( + TestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [Fact] + public async Task Precompilation_WorksForSimpleApps() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + deployment.ApplicationBaseUri, + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent("SimpleAppWithAssemblyRenameTest.Home.Index.txt", response); + } + } + + public class TestFixture : CoreCLRApplicationTestFixture + { + public TestFixture() + : base( + typeof(SimpleAppWithAssemblyRename.Startup).Assembly.GetName().Name, + ApplicationPaths.GetTestAppDirectory(nameof(SimpleAppWithAssemblyRename))) + { + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/StrongNamedAppTest_CoreCLR.cs b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/StrongNamedAppTest_CoreCLR.cs new file mode 100644 index 0000000000..4559a416fa --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/StrongNamedAppTest_CoreCLR.cs @@ -0,0 +1,42 @@ +// 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.Threading.Tasks; +using Microsoft.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + public class StrongNamedAppTest_CoreCLR : + LoggedTest, IClassFixture> + { + public StrongNamedAppTest_CoreCLR( + CoreCLRApplicationTestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [Fact] + public async Task PrecompiledAssembliesUseSameStrongNameAsApplication() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + deployment.ApplicationBaseUri, + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent("StrongNamedApp.Home.Index.txt", response); + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/ViewCompilationOptionsTest_CoreCLR.cs b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/ViewCompilationOptionsTest_CoreCLR.cs new file mode 100644 index 0000000000..6b80eca31d --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/CoreCLRTests/ViewCompilationOptionsTest_CoreCLR.cs @@ -0,0 +1,57 @@ +// 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.IO; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Server.IntegrationTesting; +using Microsoft.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + public class ViewCompilationOptions_CoreCLR_ScenarioRefAssembliesDoNotGetPublished : + LoggedTest, IClassFixture + { + public ViewCompilationOptions_CoreCLR_ScenarioRefAssembliesDoNotGetPublished( + TestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [Fact] + public async Task PublishingWithOption_AllowsPublishingRefAssemblies() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act & Assert + Assert.True(Directory.Exists(Path.Combine(deployment.ContentRoot, "refs"))); + } + } + + public class TestFixture : CoreCLRApplicationTestFixture + { + public TestFixture() + { + PublishOnly = true; + } + + protected override DeploymentParameters GetDeploymentParameters() + { + var deploymentParameters = base.GetDeploymentParameters(); + deploymentParameters.PublishEnvironmentVariables.Add( + new KeyValuePair("MvcRazorExcludeRefAssembliesFromPublish", "false")); + + return deploymentParameters; + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/ApplicationWithConfigureMvcTest_Desktop.cs b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/ApplicationWithConfigureMvcTest_Desktop.cs new file mode 100644 index 0000000000..5e2db02762 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/ApplicationWithConfigureMvcTest_Desktop.cs @@ -0,0 +1,65 @@ +// 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.Threading.Tasks; +using Microsoft.AspNetCore.Testing.xunit; +using Microsoft.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + [OSSkipCondition(OperatingSystems.Linux)] + [OSSkipCondition(OperatingSystems.MacOSX)] + public class ApplicationWithConfigureMvcTest_Desktop + : LoggedTest, IClassFixture> + { + public ApplicationWithConfigureMvcTest_Desktop( + DesktopApplicationTestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [ConditionalFact] + public async Task Precompilation_RunsConfiguredCompilationCallbacks() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + deployment.ApplicationBaseUri, + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent("ApplicationWithConfigureMvc.Home.Index.txt", response); + } + } + + [ConditionalFact] + public async Task Precompilation_UsesConfiguredParseOptions() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + "Home/ViewWithPreprocessor", + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent( + "ApplicationWithConfigureMvc.Home.ViewWithPreprocessor.txt", + response); + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/ApplicationWithCustomInputFilesTest_Desktop.cs b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/ApplicationWithCustomInputFilesTest_Desktop.cs new file mode 100644 index 0000000000..cd519e5518 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/ApplicationWithCustomInputFilesTest_Desktop.cs @@ -0,0 +1,108 @@ +// 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.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Testing.xunit; +using Microsoft.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + [OSSkipCondition(OperatingSystems.Linux)] + [OSSkipCondition(OperatingSystems.MacOSX)] + public class ApplicationWithCustomInputFilesTest_Desktop + : LoggedTest, IClassFixture> + { + public ApplicationWithCustomInputFilesTest_Desktop( + DesktopApplicationTestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [ConditionalFact] + public async Task ApplicationWithCustomInputFiles_Works() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + var expectedText = "Hello Index!"; + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + deployment.ApplicationBaseUri, + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + Assert.Equal(expectedText, response.Trim()); + } + } + + [ConditionalFact] + public async Task MvcRazorFilesToCompile_OverridesTheFilesToBeCompiled() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + var expectedViews = new[] + { + "/Views/Home/About.cshtml", + "/Views/Home/Index.cshtml", + }; + + // Act + var response2 = await deployment.HttpClient.GetStringWithRetryAsync( + "Home/GetPrecompiledResourceNames", + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + var actual = response2.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries) + .OrderBy(p => p, StringComparer.OrdinalIgnoreCase); + Assert.Equal(expectedViews, actual); + } + } + + [ConditionalFact] + public async Task MvcRazorFilesToCompile_SpecificallyDoesNotPublishFilesToBeCompiled() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + var viewsNotPublished = new[] + { + "Index.cshtml", + "About.cshtml", + }; + + var viewsPublished = new[] + { + "NotIncluded.cshtml", + }; + var viewsDirectory = Path.Combine(deployment.ContentRoot, "Views", "Home"); + + // Act & Assert + foreach (var file in viewsPublished) + { + var filePath = Path.Combine(viewsDirectory, file); + Assert.True(File.Exists(filePath), $"{filePath} was not published."); + } + + foreach (var file in viewsNotPublished) + { + var filePath = Path.Combine(viewsDirectory, file); + Assert.False(File.Exists(filePath), $"{filePath} was published."); + } + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/ApplicationWithParseErrorsTest_Desktop.cs b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/ApplicationWithParseErrorsTest_Desktop.cs new file mode 100644 index 0000000000..7c6d9a9835 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/ApplicationWithParseErrorsTest_Desktop.cs @@ -0,0 +1,52 @@ +// 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.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Testing.xunit; +using Microsoft.Extensions.Logging.Testing; +using Xunit; + +namespace FunctionalTests +{ + [OSSkipCondition(OperatingSystems.Linux)] + [OSSkipCondition(OperatingSystems.MacOSX)] + public class ApplicationWithParseErrorsTest_Desktop + : IClassFixture> + { + public ApplicationWithParseErrorsTest_Desktop(DesktopApplicationTestFixture fixture) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [ConditionalFact(Skip = "Flaky test in many build configurations.See issue #277.")] + public async Task PublishingPrintsParseErrors() + { + // Arrange + var indexPath = Path.Combine(Fixture.TestProjectDirectory, "Views", "Home", "Index.cshtml"); + var viewImportsPath = Path.Combine(Fixture.TestProjectDirectory, "Views", "Home", "About.cshtml"); + var expectedErrors = new[] + { + indexPath + " (0): The code block is missing a closing \"}\" character. Make sure you have a matching \"}\" character for all the \"{\" characters within this block, and that none of the \"}\" characters are being interpreted as markup.", + viewImportsPath + " (1): A space or line break was encountered after the \"@\" character. Only valid identifiers, keywords, comments, \"(\" and \"{\" are valid at the start of a code block and they must occur immediately following \"@\" with no space in between.", + + }; + var testSink = new TestSink(); + var loggerFactory = new TestLoggerFactory(testSink, enabled: true); + + // Act + await Assert.ThrowsAsync(() => Fixture.CreateDeploymentAsync(loggerFactory)); + + // Assert + var logs = testSink.Writes.Select(w => w.State.ToString().Trim()).ToList(); + foreach (var expectedError in expectedErrors) + { + Assert.Contains(logs, log => log.Contains(expectedError)); + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/ApplicationWithTagHelpersTest_Desktop.cs b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/ApplicationWithTagHelpersTest_Desktop.cs new file mode 100644 index 0000000000..68d661e2d8 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/ApplicationWithTagHelpersTest_Desktop.cs @@ -0,0 +1,78 @@ +// 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; +using Microsoft.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + [OSSkipCondition(OperatingSystems.Linux)] + [OSSkipCondition(OperatingSystems.MacOSX)] + public class ApplicationWithTagHelpersTest_Desktop : + LoggedTest, IClassFixture + { + public ApplicationWithTagHelpersTest_Desktop( + ApplicationWithTagHelpersTestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [ConditionalFact] + public async Task Precompilation_WorksForViewsThatUseTagHelpersFromProjectReferences() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + "Home/ClassLibraryTagHelper", + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent($"ApplicationWithTagHelpers.Home.ClassLibraryTagHelper.txt", response); + } + } + + [ConditionalFact] + public async Task Precompilation_WorksForViewsThatUseTagHelpersFromCurrentProject() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + "Home/LocalTagHelper", + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent($"ApplicationWithTagHelpers.Home.LocalTagHelper.txt", response); + } + } + + public class ApplicationWithTagHelpersTestFixture : DesktopApplicationTestFixture + { + protected override Task CreateDeploymentAsyncCore(ILoggerFactory loggerFactory) + { + CopyDirectory( + new DirectoryInfo(Path.Combine(ApplicationPath, "..", "ClassLibraryTagHelper")), + new DirectoryInfo(Path.Combine(WorkingDirectory, "ClassLibraryTagHelper"))); + + return base.CreateDeploymentAsyncCore(loggerFactory); + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/PublishWithEmbedViewSourcesTest_Desktop.cs b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/PublishWithEmbedViewSourcesTest_Desktop.cs new file mode 100644 index 0000000000..eea2b45da7 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/PublishWithEmbedViewSourcesTest_Desktop.cs @@ -0,0 +1,65 @@ +// 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.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Testing.xunit; +using Microsoft.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + [OSSkipCondition(OperatingSystems.Linux)] + [OSSkipCondition(OperatingSystems.MacOSX)] + public class PublishWithEmbedViewSourcesTest_Desktop + : LoggedTest, IClassFixture> + { + public PublishWithEmbedViewSourcesTest_Desktop( + DesktopApplicationTestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [ConditionalFact] + public async Task Precompilation_CanEmbedViewSourcesAsResources() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + var logger = loggerFactory.CreateLogger(Fixture.ApplicationName); + var expectedViews = new[] + { + "/Areas/TestArea/Views/Home/Index.cshtml", + "/Views/Home/About.cshtml", + "/Views/Home/Index.cshtml", + }; + var expectedText = "Hello Index!"; + + // Act - 1 + var response1 = await deployment.HttpClient.GetStringWithRetryAsync( + "Home/Index", + logger); + + // Assert - 1 + Assert.Equal(expectedText, response1.Trim()); + + // Act - 2 + var response2 = await deployment.HttpClient.GetStringWithRetryAsync( + "Home/GetPrecompiledResourceNames", + logger); + + // Assert - 2 + var actual = response2.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries) + .OrderBy(p => p, StringComparer.OrdinalIgnoreCase); + Assert.Equal(expectedViews, actual); + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/RazorPagesAppTest_Desktop.cs b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/RazorPagesAppTest_Desktop.cs new file mode 100644 index 0000000000..bbdf42bdaf --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/RazorPagesAppTest_Desktop.cs @@ -0,0 +1,137 @@ +// 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.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)] + [OSSkipCondition(OperatingSystems.MacOSX)] + public class RazorPagesAppTest_Desktop : + LoggedTest, IClassFixture> + { + public RazorPagesAppTest_Desktop( + DesktopApplicationTestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [ConditionalFact] + public async Task Precompilation_WorksForIndexPage_UsingFolderName() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + "/", + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent("RazorPages.Index.txt", response); + } + } + + [ConditionalFact] + public async Task Precompilation_WorksForIndexPage_UsingFileName() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + "/Index", + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent("RazorPages.Index.txt", response); + } + } + + [ConditionalFact] + public async Task Precompilation_WorksForPageWithModel() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + "/PageWithModel?person=Dan", + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent("RazorPages.PageWithModel.txt", response); + } + } + + [ConditionalFact] + public async Task Precompilation_WorksForPageWithRoute() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + "/PageWithRoute/Dan", + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent("RazorPages.PageWithRoute.txt", response); + } + } + + [ConditionalFact] + public async Task Precompilation_WorksForPageInNestedFolder() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + "/Nested1/Nested2/PageWithTagHelper", + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent("RazorPages.Nested1.Nested2.PageWithTagHelper.txt", response); + } + } + + [ConditionalFact] + public async Task Precompilation_WorksWithPageConventions() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await RetryHelper.RetryRequest( + () => deployment.HttpClient.GetAsync("/Auth/Index"), + loggerFactory.CreateLogger(Fixture.ApplicationName), + retryCount: 5); + + // Assert + Assert.Equal("/Login?ReturnUrl=%2FAuth%2FIndex", response.RequestMessage.RequestUri.PathAndQuery); + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/SimpleAppTestWithPlatformx86_Desktop.cs b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/SimpleAppTestWithPlatformx86_Desktop.cs new file mode 100644 index 0000000000..ca47095612 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/SimpleAppTestWithPlatformx86_Desktop.cs @@ -0,0 +1,57 @@ +// 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.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)] + [OSSkipCondition(OperatingSystems.MacOSX)] + public class SimpleAppTestWithPlatformx86_Desktop : + LoggedTest, IClassFixture> + { + public SimpleAppTestWithPlatformx86_Desktop( + DesktopApplicationTestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [ConditionalFact] + public async Task Precompilation_PublishingForPlatform() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + deployment.ApplicationBaseUri, + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent("SimpleAppTest.Home.Index.txt", response); + } + } + + public class SimpleAppTestWithPlatformx86_DesktopFixture : DesktopApplicationTestFixture + { + protected override DeploymentParameters GetDeploymentParameters() + { + var parameters = base.GetDeploymentParameters(); + parameters.AdditionalPublishParameters = "/p:Platform=x86"; + + return parameters; + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/SimpleAppWithAssemblyRenameTest_Desktop.cs b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/SimpleAppWithAssemblyRenameTest_Desktop.cs new file mode 100644 index 0000000000..bb16ce3dea --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/SimpleAppWithAssemblyRenameTest_Desktop.cs @@ -0,0 +1,55 @@ +// 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.Threading.Tasks; +using Microsoft.AspNetCore.Testing.xunit; +using Microsoft.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + [OSSkipCondition(OperatingSystems.Linux)] + [OSSkipCondition(OperatingSystems.MacOSX)] + public class SimpleAppWithAssemblyRenameTest_Desktop : + LoggedTest, IClassFixture + { + public SimpleAppWithAssemblyRenameTest_Desktop( + TestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [ConditionalFact] + public async Task Precompilation_WorksForSimpleApps() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + deployment.ApplicationBaseUri, + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent("SimpleAppWithAssemblyRenameTest.Home.Index.txt", response); + } + } + + public class TestFixture : DesktopApplicationTestFixture + { + public TestFixture() + : base( + typeof(SimpleAppWithAssemblyRename.Startup).Assembly.GetName().Name, + ApplicationPaths.GetTestAppDirectory(nameof(SimpleAppWithAssemblyRename))) + { + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/StrongNamedAppTest_Desktop.cs b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/StrongNamedAppTest_Desktop.cs new file mode 100644 index 0000000000..16f63fbe3b --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/StrongNamedAppTest_Desktop.cs @@ -0,0 +1,45 @@ +// 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.Threading.Tasks; +using Microsoft.AspNetCore.Testing.xunit; +using Microsoft.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + [OSSkipCondition(OperatingSystems.Linux)] + [OSSkipCondition(OperatingSystems.MacOSX)] + public class StrongNamedAppTest_Desktop : + LoggedTest, IClassFixture> + { + public StrongNamedAppTest_Desktop( + DesktopApplicationTestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [ConditionalFact] + public async Task PrecompiledAssembliesUseSameStrongNameAsApplication() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + deployment.ApplicationBaseUri, + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + TestEmbeddedResource.AssertContent("StrongNamedApp.Home.Index.txt", response); + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/ViewCompilationOptionsTest_Desktop.cs b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/ViewCompilationOptionsTest_Desktop.cs new file mode 100644 index 0000000000..053b7456a9 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/DesktopTests/ViewCompilationOptionsTest_Desktop.cs @@ -0,0 +1,60 @@ +// 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.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)] + [OSSkipCondition(OperatingSystems.MacOSX)] + public class ViewCompilationOptions_Desktop_ScenarioRefAssembliesDoNotGetPublished : + LoggedTest, IClassFixture + { + public ViewCompilationOptions_Desktop_ScenarioRefAssembliesDoNotGetPublished( + TestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [ConditionalFact] + public async Task PublishingWithOption_AllowsPublishingRefAssemblies() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act & Assert + Assert.True(Directory.Exists(Path.Combine(deployment.ContentRoot, "refs"))); + } + } + + public class TestFixture : DesktopApplicationTestFixture + { + public TestFixture() + { + PublishOnly = true; + } + + protected override DeploymentParameters GetDeploymentParameters() + { + var deploymentParameters = base.GetDeploymentParameters(); + deploymentParameters.PublishEnvironmentVariables.Add( + new KeyValuePair("MvcRazorExcludeRefAssembliesFromPublish", "false")); + + return deploymentParameters; + } + } + } +} diff --git a/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationConsumingPrecompiledViews.Manage.Home.Index.txt b/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationConsumingPrecompiledViews.Manage.Home.Index.txt new file mode 100644 index 0000000000..e4baad155e --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationConsumingPrecompiledViews.Manage.Home.Index.txt @@ -0,0 +1,13 @@ + + + + ClassLibraryWithPrecompiledViews.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + +

Admin home page

+ + + + Test section + + + diff --git a/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationUsingRelativePaths.Home.About.txt b/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationUsingRelativePaths.Home.About.txt new file mode 100644 index 0000000000..c3b073162c --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationUsingRelativePaths.Home.About.txt @@ -0,0 +1,8 @@ + + + + +ApplicationUsingRelativePaths.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null +Hello from Index! + + \ No newline at end of file diff --git a/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationUsingRelativePaths.Home.Index.txt b/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationUsingRelativePaths.Home.Index.txt new file mode 100644 index 0000000000..c3b073162c --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationUsingRelativePaths.Home.Index.txt @@ -0,0 +1,8 @@ + + + + +ApplicationUsingRelativePaths.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null +Hello from Index! + + \ No newline at end of file diff --git a/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationWithConfigureMvc.Home.Index.txt b/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationWithConfigureMvc.Home.Index.txt new file mode 100644 index 0000000000..6ed3f16836 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationWithConfigureMvc.Home.Index.txt @@ -0,0 +1,2 @@ +ApplicationWithConfigureMvc.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null +
Hello world! \ No newline at end of file diff --git a/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationWithConfigureMvc.Home.ViewWithPreprocessor.txt b/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationWithConfigureMvc.Home.ViewWithPreprocessor.txt new file mode 100644 index 0000000000..8d0df2adff --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationWithConfigureMvc.Home.ViewWithPreprocessor.txt @@ -0,0 +1 @@ +Hello from Test123 \ No newline at end of file diff --git a/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationWithRazorSdkPrecompilationUsed.Home.Index.txt b/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationWithRazorSdkPrecompilationUsed.Home.Index.txt new file mode 100644 index 0000000000..ed399bf490 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationWithRazorSdkPrecompilationUsed.Home.Index.txt @@ -0,0 +1,8 @@ + + + + +ApplicationWithRazorSdkPrecompilationUsed.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null +Hello from Index! + + \ No newline at end of file diff --git a/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationWithRazorSdkUsed.Home.Index.txt b/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationWithRazorSdkUsed.Home.Index.txt new file mode 100644 index 0000000000..ed93ca56a8 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationWithRazorSdkUsed.Home.Index.txt @@ -0,0 +1,8 @@ + + + + +ApplicationWithRazorSdkUsed.Views, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null +Hello from Index! + + \ No newline at end of file diff --git a/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationWithTagHelpers.Home.ClassLibraryTagHelper.txt b/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationWithTagHelpers.Home.ClassLibraryTagHelper.txt new file mode 100644 index 0000000000..f3a28a4d23 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationWithTagHelpers.Home.ClassLibraryTagHelper.txt @@ -0,0 +1,25 @@ + + + + - ApplicationWithTagHelpers + + + + +
+ +ApplicationWithTagHelpers.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null +
To boldy tag that no one has ever tagged before...
+ + + + +
+
+

© 2016 - ApplicationWithTagHelpers

+
+
+ + ApplicationWithTagHelpers.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + diff --git a/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationWithTagHelpers.Home.LocalTagHelper.txt b/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationWithTagHelpers.Home.LocalTagHelper.txt new file mode 100644 index 0000000000..43afc098bd --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/Resources/ApplicationWithTagHelpers.Home.LocalTagHelper.txt @@ -0,0 +1,25 @@ + + + + - ApplicationWithTagHelpers + + + + +
+ +ApplicationWithTagHelpers.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null +TestTagHelper content. + + + + +
+
+

© 2016 - ApplicationWithTagHelpers

+
+
+ + ApplicationWithTagHelpers.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + diff --git a/src/MvcPrecompilation/test/FunctionalTests/Resources/RazorPages.Index.txt b/src/MvcPrecompilation/test/FunctionalTests/Resources/RazorPages.Index.txt new file mode 100644 index 0000000000..ff3f1d2458 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/Resources/RazorPages.Index.txt @@ -0,0 +1,2 @@ + +Hello world! \ No newline at end of file diff --git a/src/MvcPrecompilation/test/FunctionalTests/Resources/RazorPages.Nested1.Nested2.PageWithTagHelper.txt b/src/MvcPrecompilation/test/FunctionalTests/Resources/RazorPages.Nested1.Nested2.PageWithTagHelper.txt new file mode 100644 index 0000000000..9cf6533fae --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/Resources/RazorPages.Nested1.Nested2.PageWithTagHelper.txt @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/MvcPrecompilation/test/FunctionalTests/Resources/RazorPages.PageWithModel.txt b/src/MvcPrecompilation/test/FunctionalTests/Resources/RazorPages.PageWithModel.txt new file mode 100644 index 0000000000..1cdbdae92e --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/Resources/RazorPages.PageWithModel.txt @@ -0,0 +1,2 @@ + +Greetings Dan! \ No newline at end of file diff --git a/src/MvcPrecompilation/test/FunctionalTests/Resources/RazorPages.PageWithRoute.txt b/src/MvcPrecompilation/test/FunctionalTests/Resources/RazorPages.PageWithRoute.txt new file mode 100644 index 0000000000..1cdbdae92e --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/Resources/RazorPages.PageWithRoute.txt @@ -0,0 +1,2 @@ + +Greetings Dan! \ No newline at end of file diff --git a/src/MvcPrecompilation/test/FunctionalTests/Resources/SimpleAppWithAssemblyRenameTest.Home.Index.txt b/src/MvcPrecompilation/test/FunctionalTests/Resources/SimpleAppWithAssemblyRenameTest.Home.Index.txt new file mode 100644 index 0000000000..29d346230b --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/Resources/SimpleAppWithAssemblyRenameTest.Home.Index.txt @@ -0,0 +1,2 @@ + +NewAssemblyName.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null \ No newline at end of file diff --git a/src/MvcPrecompilation/test/FunctionalTests/Resources/StrongNamedApp.Home.Index.txt b/src/MvcPrecompilation/test/FunctionalTests/Resources/StrongNamedApp.Home.Index.txt new file mode 100644 index 0000000000..edfb07d5d7 --- /dev/null +++ b/src/MvcPrecompilation/test/FunctionalTests/Resources/StrongNamedApp.Home.Index.txt @@ -0,0 +1 @@ +Hello from view in StrongNamedApp.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 diff --git a/src/MvcPrecompilation/testapps/ApplicationWithConfigureMvc/Startup.cs b/src/MvcPrecompilation/testapps/ApplicationWithConfigureMvc/Startup.cs index 9c44e7a17d..bad4439448 100644 --- a/src/MvcPrecompilation/testapps/ApplicationWithConfigureMvc/Startup.cs +++ b/src/MvcPrecompilation/testapps/ApplicationWithConfigureMvc/Startup.cs @@ -9,7 +9,6 @@ namespace ApplicationWithConfigureStartup { public void ConfigureServices(IServiceCollection services) { - services.AddLogging(loggingBuilder => loggingBuilder.AddConsole()); // Add framework services. var builder = services.AddMvc(); ConfigureMvc(builder); @@ -17,6 +16,7 @@ namespace ApplicationWithConfigureStartup public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { + loggerFactory.AddConsole(); app.UseMvc(routes => { routes.MapRoute( diff --git a/src/MvcPrecompilation/testapps/ApplicationWithCustomInputFiles/Startup.cs b/src/MvcPrecompilation/testapps/ApplicationWithCustomInputFiles/Startup.cs index 203395ded9..d42b8dfad9 100644 --- a/src/MvcPrecompilation/testapps/ApplicationWithCustomInputFiles/Startup.cs +++ b/src/MvcPrecompilation/testapps/ApplicationWithCustomInputFiles/Startup.cs @@ -8,13 +8,13 @@ namespace ApplicationWithCustomInputFiles { public void ConfigureServices(IServiceCollection services) { - services.AddLogging(loggingBuilder => loggingBuilder.AddConsole()); // Add framework services. services.AddMvc(); } public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { + loggerFactory.AddConsole(); app.UseMvc(routes => { routes.MapRoute( diff --git a/src/MvcPrecompilation/testapps/ApplicationWithParseErrors/Startup.cs b/src/MvcPrecompilation/testapps/ApplicationWithParseErrors/Startup.cs index 8e2df21cc8..b573e39a8c 100644 --- a/src/MvcPrecompilation/testapps/ApplicationWithParseErrors/Startup.cs +++ b/src/MvcPrecompilation/testapps/ApplicationWithParseErrors/Startup.cs @@ -8,12 +8,12 @@ namespace ApplicationWithParseErrors { public void ConfigureServices(IServiceCollection services) { - services.AddLogging(loggingBuilder => loggingBuilder.AddConsole()); services.AddMvc(); } public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { + loggerFactory.AddConsole(); app.UseMvcWithDefaultRoute(); } } diff --git a/src/MvcPrecompilation/testapps/ApplicationWithRazorSdkNeitherUsed/Startup.cs b/src/MvcPrecompilation/testapps/ApplicationWithRazorSdkNeitherUsed/Startup.cs index c7068b7faa..4b06309f6d 100644 --- a/src/MvcPrecompilation/testapps/ApplicationWithRazorSdkNeitherUsed/Startup.cs +++ b/src/MvcPrecompilation/testapps/ApplicationWithRazorSdkNeitherUsed/Startup.cs @@ -8,13 +8,13 @@ namespace ApplicationWithRazorSdkNeitherUsed { public void ConfigureServices(IServiceCollection services) { - services.AddLogging(loggingBuilder => loggingBuilder.AddConsole()); // Add framework services. services.AddMvc(); } public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { + loggerFactory.AddConsole(); app.UseMvcWithDefaultRoute(); } } diff --git a/src/MvcPrecompilation/testapps/ApplicationWithRazorSdkPrecompilationUsed/Startup.cs b/src/MvcPrecompilation/testapps/ApplicationWithRazorSdkPrecompilationUsed/Startup.cs index d168b9394c..16c835e52d 100644 --- a/src/MvcPrecompilation/testapps/ApplicationWithRazorSdkPrecompilationUsed/Startup.cs +++ b/src/MvcPrecompilation/testapps/ApplicationWithRazorSdkPrecompilationUsed/Startup.cs @@ -8,13 +8,13 @@ namespace ApplicationWithRazorSdkPrecompilationUsed { public void ConfigureServices(IServiceCollection services) { - services.AddLogging(loggingBuilder => loggingBuilder.AddConsole()); // Add framework services. services.AddMvc(); } public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { + loggerFactory.AddConsole(); app.UseMvcWithDefaultRoute(); } } diff --git a/src/MvcPrecompilation/testapps/ApplicationWithRazorSdkUsed/Startup.cs b/src/MvcPrecompilation/testapps/ApplicationWithRazorSdkUsed/Startup.cs index 49a97f8e40..8c6e88ed12 100644 --- a/src/MvcPrecompilation/testapps/ApplicationWithRazorSdkUsed/Startup.cs +++ b/src/MvcPrecompilation/testapps/ApplicationWithRazorSdkUsed/Startup.cs @@ -8,13 +8,13 @@ namespace ApplicationWithRazorSdkUsed { public void ConfigureServices(IServiceCollection services) { - services.AddLogging(loggingBuilder => loggingBuilder.AddConsole()); // Add framework services. services.AddMvc(); } public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { + loggerFactory.AddConsole(); app.UseMvcWithDefaultRoute(); } } diff --git a/src/MvcPrecompilation/testapps/ApplicationWithTagHelpers/Startup.cs b/src/MvcPrecompilation/testapps/ApplicationWithTagHelpers/Startup.cs index 48babe25f2..00a0fb6df9 100644 --- a/src/MvcPrecompilation/testapps/ApplicationWithTagHelpers/Startup.cs +++ b/src/MvcPrecompilation/testapps/ApplicationWithTagHelpers/Startup.cs @@ -8,13 +8,13 @@ namespace ApplicationWithTagHelpers { public void ConfigureServices(IServiceCollection services) { - services.AddLogging(loggingBuilder => loggingBuilder.AddConsole()); // Add framework services. services.AddMvc(); } public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { + loggerFactory.AddConsole(); app.UseMvc(routes => { routes.MapRoute( diff --git a/src/MvcPrecompilation/testapps/PublishWithEmbedViewSources/Startup.cs b/src/MvcPrecompilation/testapps/PublishWithEmbedViewSources/Startup.cs index d7dee03fff..c1e951b594 100644 --- a/src/MvcPrecompilation/testapps/PublishWithEmbedViewSources/Startup.cs +++ b/src/MvcPrecompilation/testapps/PublishWithEmbedViewSources/Startup.cs @@ -8,13 +8,13 @@ namespace PublishWithEmbedViewSources { public void ConfigureServices(IServiceCollection services) { - services.AddLogging(loggingBuilder => loggingBuilder.AddConsole()); // Add framework services. services.AddMvc(); } public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { + loggerFactory.AddConsole(); app.UseMvc(routes => { routes.MapRoute( diff --git a/src/MvcPrecompilation/testapps/RazorPagesApp/Startup.cs b/src/MvcPrecompilation/testapps/RazorPagesApp/Startup.cs index c90ccba906..33964de1da 100644 --- a/src/MvcPrecompilation/testapps/RazorPagesApp/Startup.cs +++ b/src/MvcPrecompilation/testapps/RazorPagesApp/Startup.cs @@ -10,7 +10,6 @@ namespace RazorPagesApp { public void ConfigureServices(IServiceCollection services) { - services.AddLogging(loggingBuilder => loggingBuilder.AddConsole()); var builder = services.AddMvc(); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options => options.LoginPath = "/Login"); ConfigureMvc(builder); @@ -18,6 +17,7 @@ namespace RazorPagesApp public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { + loggerFactory.AddConsole(); app.UseAuthentication(); app.UseMvc(); } diff --git a/src/MvcPrecompilation/testapps/SimpleApp/Startup.cs b/src/MvcPrecompilation/testapps/SimpleApp/Startup.cs index abf9ec6423..461873a890 100644 --- a/src/MvcPrecompilation/testapps/SimpleApp/Startup.cs +++ b/src/MvcPrecompilation/testapps/SimpleApp/Startup.cs @@ -8,13 +8,13 @@ namespace SimpleApp { public void ConfigureServices(IServiceCollection services) { - services.AddLogging(loggingBuilder => loggingBuilder.AddConsole()); // Add framework services. services.AddMvc(); } public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { + loggerFactory.AddConsole(); app.UseMvc(routes => { routes.MapRoute( diff --git a/src/MvcPrecompilation/testapps/SimpleAppWithAssemblyRename/Startup.cs b/src/MvcPrecompilation/testapps/SimpleAppWithAssemblyRename/Startup.cs index 4492a3912b..fa29d5b735 100644 --- a/src/MvcPrecompilation/testapps/SimpleAppWithAssemblyRename/Startup.cs +++ b/src/MvcPrecompilation/testapps/SimpleAppWithAssemblyRename/Startup.cs @@ -8,13 +8,13 @@ namespace SimpleAppWithAssemblyRename { public void ConfigureServices(IServiceCollection services) { - services.AddLogging(loggingBuilder => loggingBuilder.AddConsole()); // Add framework services. services.AddMvc(); } public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { + loggerFactory.AddConsole(); app.UseMvcWithDefaultRoute(); } } diff --git a/src/MvcPrecompilation/testapps/StrongNamedApp/Startup.cs b/src/MvcPrecompilation/testapps/StrongNamedApp/Startup.cs index f5dc4b4640..a75f450846 100644 --- a/src/MvcPrecompilation/testapps/StrongNamedApp/Startup.cs +++ b/src/MvcPrecompilation/testapps/StrongNamedApp/Startup.cs @@ -8,13 +8,13 @@ namespace StrongNamedApp { public void ConfigureServices(IServiceCollection services) { - services.AddLogging(loggingBuilder => loggingBuilder.AddConsole()); // Add framework services. services.AddMvc(); } public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { + loggerFactory.AddConsole(); app.UseMvc(routes => { routes.MapRoute( diff --git a/src/MvcPrecompilation/version.props b/src/MvcPrecompilation/version.props index 4889a26987..71a78cddd8 100644 --- a/src/MvcPrecompilation/version.props +++ b/src/MvcPrecompilation/version.props @@ -1,7 +1,7 @@ - + - 2.2.0 - rtm + 3.0.0 + alpha1 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000