diff --git a/src/Components/Authorization/ref/Microsoft.AspNetCore.Components.Authorization.csproj b/src/Components/Authorization/ref/Microsoft.AspNetCore.Components.Authorization.csproj index 53db4b90de..238b4804b0 100644 --- a/src/Components/Authorization/ref/Microsoft.AspNetCore.Components.Authorization.csproj +++ b/src/Components/Authorization/ref/Microsoft.AspNetCore.Components.Authorization.csproj @@ -1,15 +1,9 @@ - netstandard2.0;$(DefaultNetCoreTargetFramework) - $(DefaultNetCoreTargetFramework) + $(DefaultNetCoreTargetFramework) - - - - - - + diff --git a/src/Components/Authorization/src/Microsoft.AspNetCore.Components.Authorization.csproj b/src/Components/Authorization/src/Microsoft.AspNetCore.Components.Authorization.csproj index fa9f682772..9cf597d035 100644 --- a/src/Components/Authorization/src/Microsoft.AspNetCore.Components.Authorization.csproj +++ b/src/Components/Authorization/src/Microsoft.AspNetCore.Components.Authorization.csproj @@ -1,12 +1,10 @@ - netstandard2.0;$(DefaultNetCoreTargetFramework) - $(DefaultNetCoreTargetFramework) + $(DefaultNetCoreTargetFramework) true Authentication and authorization support for Blazor applications. true - 3.0 diff --git a/src/Components/Components/ref/Microsoft.AspNetCore.Components.csproj b/src/Components/Components/ref/Microsoft.AspNetCore.Components.csproj index c09fdf223f..a5dade5e0b 100644 --- a/src/Components/Components/ref/Microsoft.AspNetCore.Components.csproj +++ b/src/Components/Components/ref/Microsoft.AspNetCore.Components.csproj @@ -1,19 +1,10 @@ - netstandard2.0;$(DefaultNetCoreTargetFramework) - $(DefaultNetCoreTargetFramework) + $(DefaultNetCoreTargetFramework) annotations - - - - - - - - - + diff --git a/src/Components/Components/src/Microsoft.AspNetCore.Components.csproj b/src/Components/Components/src/Microsoft.AspNetCore.Components.csproj index 17d04fad28..7565534a51 100644 --- a/src/Components/Components/src/Microsoft.AspNetCore.Components.csproj +++ b/src/Components/Components/src/Microsoft.AspNetCore.Components.csproj @@ -1,8 +1,7 @@ - netstandard2.0;$(DefaultNetCoreTargetFramework) - $(DefaultNetCoreTargetFramework) + $(DefaultNetCoreTargetFramework) Components feature for ASP.NET Core. true true @@ -17,19 +16,12 @@ - - - - - - - @@ -38,27 +30,25 @@ BuildInParallel="$(BuildInParallel)" Projects=" ../../Analyzers/src/Microsoft.AspNetCore.Components.Analyzers.csproj; - ../../../JSInterop/Microsoft.JSInterop/src/Microsoft.JSInterop.csproj; ../../../Security/Authorization/Core/src/Microsoft.AspNetCore.Authorization.csproj"> - - Microsoft.AspNetCore.Components.multitarget.nuspec - Microsoft.AspNetCore.Components.netcoreapp.nuspec + Microsoft.AspNetCore.Components.netcoreapp.nuspec $(GenerateNuspecDependsOn);_GetNuspecDependencyPackageVersions + diff --git a/src/Components/Components/src/Microsoft.AspNetCore.Components.multitarget.nuspec b/src/Components/Components/src/Microsoft.AspNetCore.Components.multitarget.nuspec deleted file mode 100644 index dec35ae173..0000000000 --- a/src/Components/Components/src/Microsoft.AspNetCore.Components.multitarget.nuspec +++ /dev/null @@ -1,26 +0,0 @@ - - - - $CommonMetadataElements$ - - - - - - - - - - - - - - - - $CommonFileElements$ - - - - - - diff --git a/src/Components/Components/src/Microsoft.AspNetCore.Components.netcoreapp.nuspec b/src/Components/Components/src/Microsoft.AspNetCore.Components.netcoreapp.nuspec index ffd63e9b69..6891e553c9 100644 --- a/src/Components/Components/src/Microsoft.AspNetCore.Components.netcoreapp.nuspec +++ b/src/Components/Components/src/Microsoft.AspNetCore.Components.netcoreapp.nuspec @@ -6,15 +6,14 @@ - $CommonFileElements$ - - - + + + diff --git a/src/Components/Components/src/Routing/RouteTableFactory.cs b/src/Components/Components/src/Routing/RouteTableFactory.cs index d1e2991f5f..4f66d660f7 100644 --- a/src/Components/Components/src/Routing/RouteTableFactory.cs +++ b/src/Components/Components/src/Routing/RouteTableFactory.cs @@ -221,7 +221,7 @@ namespace Microsoft.AspNetCore.Components public override int GetHashCode() { - var hash = new HashCodeCombiner(); + var hash = new HashCode(); if (Assemblies != null) { @@ -231,7 +231,7 @@ namespace Microsoft.AspNetCore.Components } } - return hash; + return hash.ToHashCode(); } } } diff --git a/src/Components/Forms/ref/Microsoft.AspNetCore.Components.Forms.csproj b/src/Components/Forms/ref/Microsoft.AspNetCore.Components.Forms.csproj index ce5bb3e814..6186022f8a 100644 --- a/src/Components/Forms/ref/Microsoft.AspNetCore.Components.Forms.csproj +++ b/src/Components/Forms/ref/Microsoft.AspNetCore.Components.Forms.csproj @@ -1,16 +1,10 @@ - netstandard2.0;$(DefaultNetCoreTargetFramework) - $(DefaultNetCoreTargetFramework) + $(DefaultNetCoreTargetFramework) annotations - - - - - - + diff --git a/src/Components/Forms/src/Microsoft.AspNetCore.Components.Forms.csproj b/src/Components/Forms/src/Microsoft.AspNetCore.Components.Forms.csproj index 51d866333d..05b13e543b 100644 --- a/src/Components/Forms/src/Microsoft.AspNetCore.Components.Forms.csproj +++ b/src/Components/Forms/src/Microsoft.AspNetCore.Components.Forms.csproj @@ -1,8 +1,7 @@  - netstandard2.0;$(DefaultNetCoreTargetFramework) - $(DefaultNetCoreTargetFramework) + $(DefaultNetCoreTargetFramework) true Forms and validation support for Blazor applications. true @@ -13,8 +12,4 @@ - - - - diff --git a/src/Components/Web/ref/Microsoft.AspNetCore.Components.Web.csproj b/src/Components/Web/ref/Microsoft.AspNetCore.Components.Web.csproj index e472ff807e..5ea34c6c96 100644 --- a/src/Components/Web/ref/Microsoft.AspNetCore.Components.Web.csproj +++ b/src/Components/Web/ref/Microsoft.AspNetCore.Components.Web.csproj @@ -1,19 +1,10 @@ - netstandard2.0;$(DefaultNetCoreTargetFramework) - $(DefaultNetCoreTargetFramework) + $(DefaultNetCoreTargetFramework) annotations - - - - - - - - - + diff --git a/src/Components/Web/src/Microsoft.AspNetCore.Components.Web.csproj b/src/Components/Web/src/Microsoft.AspNetCore.Components.Web.csproj index 91e8233764..39db3a0be9 100644 --- a/src/Components/Web/src/Microsoft.AspNetCore.Components.Web.csproj +++ b/src/Components/Web/src/Microsoft.AspNetCore.Components.Web.csproj @@ -1,8 +1,7 @@ - netstandard2.0;$(DefaultNetCoreTargetFramework) - $(DefaultNetCoreTargetFramework) + $(DefaultNetCoreTargetFramework) true Support for rendering ASP.NET Core components for browsers. true diff --git a/src/Components/WebAssembly/Authentication.Msal/src/Microsoft.Authentication.WebAssembly.Msal.csproj b/src/Components/WebAssembly/Authentication.Msal/src/Microsoft.Authentication.WebAssembly.Msal.csproj index 09b63f4ed3..4b27caa77b 100644 --- a/src/Components/WebAssembly/Authentication.Msal/src/Microsoft.Authentication.WebAssembly.Msal.csproj +++ b/src/Components/WebAssembly/Authentication.Msal/src/Microsoft.Authentication.WebAssembly.Msal.csproj @@ -3,9 +3,8 @@ - netstandard2.1 + $(DefaultNetCoreTargetFramework) Authenticate your Blazor webassembly applications with Azure Active Directory and Azure Active Directory B2C - 3.0 true diff --git a/src/Components/WebAssembly/JSInterop/src/Microsoft.JSInterop.WebAssembly.csproj b/src/Components/WebAssembly/JSInterop/src/Microsoft.JSInterop.WebAssembly.csproj index a14e8dadc1..64d0f52e10 100644 --- a/src/Components/WebAssembly/JSInterop/src/Microsoft.JSInterop.WebAssembly.csproj +++ b/src/Components/WebAssembly/JSInterop/src/Microsoft.JSInterop.WebAssembly.csproj @@ -1,7 +1,7 @@  - netstandard2.1 + $(DefaultNetCoreTargetFramework) Abstractions and features for interop between .NET WebAssembly and JavaScript code. wasm;javascript;interop true diff --git a/src/Components/WebAssembly/WebAssembly.Authentication/src/Microsoft.AspNetCore.Components.WebAssembly.Authentication.csproj b/src/Components/WebAssembly/WebAssembly.Authentication/src/Microsoft.AspNetCore.Components.WebAssembly.Authentication.csproj index e95a695685..dbc2d3a1a8 100644 --- a/src/Components/WebAssembly/WebAssembly.Authentication/src/Microsoft.AspNetCore.Components.WebAssembly.Authentication.csproj +++ b/src/Components/WebAssembly/WebAssembly.Authentication/src/Microsoft.AspNetCore.Components.WebAssembly.Authentication.csproj @@ -3,10 +3,9 @@ - netstandard2.1 + $(DefaultNetCoreTargetFramework) Build client-side authentication for single-page applications (SPAs). true - 3.0 true diff --git a/src/Components/WebAssembly/WebAssembly/src/Microsoft.AspNetCore.Components.WebAssembly.csproj b/src/Components/WebAssembly/WebAssembly/src/Microsoft.AspNetCore.Components.WebAssembly.csproj index 226f0d77e9..4dde2eaae6 100644 --- a/src/Components/WebAssembly/WebAssembly/src/Microsoft.AspNetCore.Components.WebAssembly.csproj +++ b/src/Components/WebAssembly/WebAssembly/src/Microsoft.AspNetCore.Components.WebAssembly.csproj @@ -1,7 +1,7 @@  - netstandard2.1 + $(DefaultNetCoreTargetFramework) Build client-side single-page applications (SPAs) with Blazor running under WebAssembly. true $(NoWarn);BL0006 @@ -44,7 +44,7 @@ - - + + diff --git a/src/Components/WebAssembly/WebAssembly/src/build/netstandard2.0/Microsoft.AspNetCore.Components.WebAssembly.props b/src/Components/WebAssembly/WebAssembly/src/build/netstandard2.0/Microsoft.AspNetCore.Components.WebAssembly.props deleted file mode 100644 index 41ae67bf35..0000000000 --- a/src/Components/WebAssembly/WebAssembly/src/build/netstandard2.0/Microsoft.AspNetCore.Components.WebAssembly.props +++ /dev/null @@ -1,5 +0,0 @@ - - - $(MSBuildThisFileDirectory)blazor.webassembly.js - - diff --git a/src/Components/WebAssembly/testassets/StandaloneApp/StandaloneApp.csproj b/src/Components/WebAssembly/testassets/StandaloneApp/StandaloneApp.csproj index 9ebf31c365..77733924cd 100644 --- a/src/Components/WebAssembly/testassets/StandaloneApp/StandaloneApp.csproj +++ b/src/Components/WebAssembly/testassets/StandaloneApp/StandaloneApp.csproj @@ -1,7 +1,7 @@ - net5.0 + $(DefaultNetCoreTargetFramework) browser-wasm true true diff --git a/src/Components/benchmarkapps/Wasm.Performance/TestApp/Wasm.Performance.TestApp.csproj b/src/Components/benchmarkapps/Wasm.Performance/TestApp/Wasm.Performance.TestApp.csproj index 54ec8b638d..84cd644558 100644 --- a/src/Components/benchmarkapps/Wasm.Performance/TestApp/Wasm.Performance.TestApp.csproj +++ b/src/Components/benchmarkapps/Wasm.Performance/TestApp/Wasm.Performance.TestApp.csproj @@ -1,7 +1,7 @@ - net5.0 + $(DefaultNetCoreTargetFramework) browser-wasm true true diff --git a/src/Components/test/testassets/TestContentPackage/TestContentPackage.csproj b/src/Components/test/testassets/TestContentPackage/TestContentPackage.csproj index f0cd18aca9..8d056bb2a8 100644 --- a/src/Components/test/testassets/TestContentPackage/TestContentPackage.csproj +++ b/src/Components/test/testassets/TestContentPackage/TestContentPackage.csproj @@ -1,9 +1,8 @@  - netstandard2.0 + $(DefaultNetCoreTargetFramework) library - 3.0 _content/TestContentPackage diff --git a/src/JSInterop/Microsoft.JSInterop/ref/Microsoft.JSInterop.csproj b/src/JSInterop/Microsoft.JSInterop/ref/Microsoft.JSInterop.csproj index dabf98ff45..a8e9ee1772 100644 --- a/src/JSInterop/Microsoft.JSInterop/ref/Microsoft.JSInterop.csproj +++ b/src/JSInterop/Microsoft.JSInterop/ref/Microsoft.JSInterop.csproj @@ -1,16 +1,10 @@ - netstandard2.0;$(DefaultNetCoreTargetFramework) - $(DefaultNetCoreTargetFramework) + $(DefaultNetCoreTargetFramework) annotations - - - - - - + diff --git a/src/JSInterop/Microsoft.JSInterop/src/Microsoft.JSInterop.csproj b/src/JSInterop/Microsoft.JSInterop/src/Microsoft.JSInterop.csproj index b49d2ea591..ebdf3cd319 100644 --- a/src/JSInterop/Microsoft.JSInterop/src/Microsoft.JSInterop.csproj +++ b/src/JSInterop/Microsoft.JSInterop/src/Microsoft.JSInterop.csproj @@ -1,8 +1,7 @@ - netstandard2.0;$(DefaultNetCoreTargetFramework) - $(DefaultNetCoreTargetFramework) + $(DefaultNetCoreTargetFramework) Abstractions and features for interop between .NET and JavaScript code. javascript;interop true diff --git a/src/JSInterop/Microsoft.JSInterop/test/Microsoft.JSInterop.Tests.csproj b/src/JSInterop/Microsoft.JSInterop/test/Microsoft.JSInterop.Tests.csproj index 41e378682e..fd443615fe 100644 --- a/src/JSInterop/Microsoft.JSInterop/test/Microsoft.JSInterop.Tests.csproj +++ b/src/JSInterop/Microsoft.JSInterop/test/Microsoft.JSInterop.Tests.csproj @@ -1,7 +1,7 @@  - $(DefaultNetCoreTargetFramework);net472 + $(DefaultNetCoreTargetFramework) enable diff --git a/src/ProjectTemplates/Web.ProjectTemplates/RazorClassLibrary-CSharp.csproj.in b/src/ProjectTemplates/Web.ProjectTemplates/RazorClassLibrary-CSharp.csproj.in index cf1a9eb26b..78d4ceaeae 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/RazorClassLibrary-CSharp.csproj.in +++ b/src/ProjectTemplates/Web.ProjectTemplates/RazorClassLibrary-CSharp.csproj.in @@ -1,9 +1,7 @@ - ${DefaultNetCoreTargetFramework} - netstandard2.0 - 3.0 + ${DefaultNetCoreTargetFramework} true Company.RazorClassLibrary1 @@ -13,7 +11,6 @@ - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorLanguageVersion.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorLanguageVersion.cs index 9fed605e2f..7913dac29b 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorLanguageVersion.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorLanguageVersion.cs @@ -20,7 +20,9 @@ namespace Microsoft.AspNetCore.Razor.Language public static readonly RazorLanguageVersion Version_3_0 = new RazorLanguageVersion(3, 0); - public static readonly RazorLanguageVersion Latest = Version_3_0; + public static readonly RazorLanguageVersion Version_5_0 = new RazorLanguageVersion(5, 0); + + public static readonly RazorLanguageVersion Latest = Version_5_0; public static readonly RazorLanguageVersion Experimental = new RazorLanguageVersion(1337, 1337); @@ -41,6 +43,11 @@ namespace Microsoft.AspNetCore.Razor.Language version = Experimental; return true; } + else if (languageVersion == "5.0") + { + version = Version_5_0; + return true; + } else if (languageVersion == "3.0") { version = Version_3_0; @@ -49,7 +56,7 @@ namespace Microsoft.AspNetCore.Razor.Language else if (languageVersion == "2.1") { version = Version_2_1; - return true; + return true; } else if (languageVersion == "2.0") { @@ -84,7 +91,7 @@ namespace Microsoft.AspNetCore.Razor.Language } throw new ArgumentException( - Resources.FormatRazorLanguageVersion_InvalidVersion(languageVersion), + Resources.FormatRazorLanguageVersion_InvalidVersion(languageVersion), nameof(languageVersion)); } @@ -131,7 +138,7 @@ namespace Microsoft.AspNetCore.Razor.Language // We don't need to do anything special for our hash code since reference equality is what we're going for. return base.GetHashCode(); } - + public override string ToString() => $"{Major}.{Minor}"; private string DebuggerToString() => $"Razor '{Major}.{Minor}'"; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs index 5b09826ebf..6122de3eb4 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs @@ -92,6 +92,20 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Same(RazorLanguageVersion.Version_3_0, version); } + [Fact] + public void TryParse50() + { + // Arrange + var value = "5.0"; + + // Act + var result = RazorLanguageVersion.TryParse(value, out var version); + + // Assert + Assert.True(result); + Assert.Same(RazorLanguageVersion.Version_5_0, version); + } + [Fact] public void TryParseLatest() { @@ -103,7 +117,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Assert Assert.True(result); - Assert.Same(RazorLanguageVersion.Version_3_0, version); + Assert.Same(RazorLanguageVersion.Version_5_0, version); } [Fact] diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/BuildIntegrationTest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/BuildIntegrationTest.cs index 4d1b03af59..b6d14278a4 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/BuildIntegrationTest.cs +++ b/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/BuildIntegrationTest.cs @@ -625,28 +625,26 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { var result = await DotnetMSBuild( "Build", - "/p:UseRazorBuildServer=false /p:RazorLangVersion=5.0", + "/p:UseRazorBuildServer=false /p:RazorLangVersion=99.0", suppressBuildServer: true); Assert.BuildFailed(result); Assert.BuildOutputContainsLine( result, - $"Invalid option 5.0 for Razor language version --version; must be Latest or a valid version in range 1.0 to 3.0."); + $"Invalid option 99.0 for Razor language version --version; must be Latest or a valid version in range 1.0 to 5.0."); // Compilation failed without creating the views assembly Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll"); Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.Views.dll"); } - [Fact(Skip = "Default C# version is 7.3 for netcoreapp3.1 and later https://github.com/dotnet/aspnetcore/issues/13930")] + [Fact] [InitializeTestProject("SimpleMvc")] public async Task Build_ImplicitCSharp8_NullableEnforcement_WarningsDuringBuild_NoBuildServer() { var result = await DotnetMSBuild( "Build", - // Remove /p:LangVersion=Default once we've picked up a compiler that supports .NET 5.0. - // Tracked by https://github.com/dotnet/aspnetcore/issues/13304 - "/p:Nullable=enable /p:LangVersion=Default", + "/p:Nullable=enable", suppressBuildServer: true); var indexFilePath = Path.Combine(RazorIntermediateOutputPath, "Views", "Home", "Index.cshtml.g.cs"); diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/BuildIntrospectionTest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/BuildIntrospectionTest.cs index c28c02c0d3..670c032036 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/BuildIntrospectionTest.cs +++ b/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/BuildIntrospectionTest.cs @@ -88,7 +88,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests } [Fact] - [InitializeTestProject("SimpleMvc")] + [InitializeTestProject("SimpleMvc31")] public async Task RazorSdk_ResolvesRazorLangVersionTo30ForNetCoreApp30Projects() { var result = await DotnetMSBuild("ResolveRazorConfiguration", "/t:_IntrospectResolvedConfiguration"); @@ -98,6 +98,17 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.BuildOutputContainsLine(result, "ResolvedRazorConfiguration: MVC-3.0"); } + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task RazorSdk_ResolvesRazorLangVersionTo50ForNetCoreApp50Projects() + { + var result = await DotnetMSBuild("ResolveRazorConfiguration", "/t:_IntrospectResolvedConfiguration"); + + Assert.BuildPassed(result); + Assert.BuildOutputContainsLine(result, "RazorLangVersion: 5.0"); + Assert.BuildOutputContainsLine(result, "ResolvedRazorConfiguration: MVC-3.0"); + } + [Fact] [InitializeTestProject("ComponentLibrary")] public async Task RazorSdk_ResolvesRazorLangVersionFromValueSpecified() @@ -142,7 +153,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests var result = await DotnetMSBuild("ResolveRazorConfiguration", "/t:_IntrospectResolvedConfiguration"); Assert.BuildPassed(result); - Assert.BuildOutputContainsLine(result, "RazorLangVersion: 3.0"); + Assert.BuildOutputContainsLine(result, "RazorLangVersion: 5.0"); Assert.BuildOutputContainsLine(result, "ResolvedRazorConfiguration: MVC-3.0"); } diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/BuildServerIntegrationTest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/BuildServerIntegrationTest.cs index 23faba7d40..041c27a955 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/BuildServerIntegrationTest.cs +++ b/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/BuildServerIntegrationTest.cs @@ -100,12 +100,12 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { var result = await DotnetMSBuild( "Build", - "/p:_RazorForceBuildServer=true /p:RazorLangVersion=5.0"); + "/p:_RazorForceBuildServer=true /p:RazorLangVersion=99.0"); Assert.BuildFailed(result); Assert.BuildOutputContainsLine( result, - $"Invalid option 5.0 for Razor language version --version; must be Latest or a valid version in range 1.0 to 3.0."); + $"Invalid option 99.0 for Razor language version --version; must be Latest or a valid version in range 1.0 to 5.0."); // Compilation failed without creating the views assembly Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll"); diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/ConfigurationMetadataIntegrationTest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/ConfigurationMetadataIntegrationTest.cs index 6d57b38214..b8518ca276 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/ConfigurationMetadataIntegrationTest.cs +++ b/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/ConfigurationMetadataIntegrationTest.cs @@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.FileContainsLine( result, razorAssemblyInfo, - "[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute(\"3.0\")]"); + "[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute(\"5.0\")]"); Assert.FileContainsLine( result, razorAssemblyInfo, diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/MvcBuildIntegrationTest31.cs b/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/MvcBuildIntegrationTest31.cs index 789ae88cb6..d737cb6b6e 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/MvcBuildIntegrationTest31.cs +++ b/src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/MvcBuildIntegrationTest31.cs @@ -1,6 +1,10 @@ // 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 Xunit; + namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { public class MvcBuildIntegrationTest31 : MvcBuildIntegrationTestLegacy @@ -12,5 +16,33 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests public override string TestProjectName => "SimpleMvc31"; public override string TargetFramework => "netcoreapp3.1"; + + [Fact] + public async Task Build_WithGenerateRazorHostingAssemblyInfo_AddsConfigurationMetadata() + { + using var project = CreateTestProject(); + + var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc31.RazorAssemblyInfo.cs"); + var result = await DotnetMSBuild("Build", "/p:GenerateRazorHostingAssemblyInfo=true"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc31.Views.dll"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc31.Views.pdb"); + + Assert.FileExists(result, razorAssemblyInfo); + Assert.FileContainsLine( + result, + razorAssemblyInfo, + "[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute(\"3.0\")]"); + Assert.FileContainsLine( + result, + razorAssemblyInfo, + "[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute(\"MVC-3.0\")]"); + Assert.FileContainsLine( + result, + razorAssemblyInfo, + "[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute(\"MVC-3.0\", \"Microsoft.AspNetCore.Mvc.Razor.Extensions\")]"); + } } } diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Configuration.targets b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Configuration.targets index 9267ba8614..98b6321759 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Configuration.targets +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Configuration.targets @@ -69,6 +69,7 @@ Copyright (c) .NET Foundation. All rights reserved. Determine the default Razor configuration --> + MVC-3.0 Default @@ -80,7 +81,7 @@ Copyright (c) .NET Foundation. All rights reserved. the project's runtime. --> - + MVC-3.0;$(CustomRazorExtension) diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets index 62dc374582..d58e2a0539 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets @@ -45,6 +45,7 @@ Copyright (c) .NET Foundation. All rights reserved. + 5.0 3.0