From 4505f76987cda3f26cbae15ef034b614591bc7e4 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 24 Jan 2019 11:40:59 -0800 Subject: [PATCH] Ensure TagHelpers from the current project are discovered for projects targeting 2.x As part of migrating the CodeGeneration targets in to the Razor.Sdk, the SDK broke the contract that RazorReferencePaths includes the full closure of assemblies during tag helper discovery. This change restores the behavior to be compatible with the 2.x Razor.Design package and adds tests to verify TagHelper discovery works in a range of projects. Fixes https://github.com/aspnet/AspNetCore/issues/6825 \n\nCommit migrated from https://github.com/dotnet/aspnetcore-tooling/commit/99938c9b7e62896060b7d6f8a225cceb28da2c8d --- ...osoft.NET.Sdk.Razor.CodeGeneration.targets | 9 ++--- ...icrosoft.NET.Sdk.Razor.Compilation.targets | 3 +- .../Microsoft.NET.Sdk.Razor.Component.targets | 2 +- .../Sdk.Razor.CurrentVersion.targets | 34 +++++++++++++------ .../BuildIntegrationTest21.cs | 9 +++++ .../BuildIntegrationTest22.cs | 9 +++++ .../BuildServerIntegrationTest.cs | 5 +++ .../MvcWithComponents/SimpleTagHelper.cs | 8 +++++ .../testassets/SimpleMvc21/SimpleTagHelper.cs | 8 +++++ .../testassets/SimpleMvc22/SimpleTagHelper.cs | 8 +++++ 10 files changed, 77 insertions(+), 18 deletions(-) create mode 100644 src/Razor/test/testassets/MvcWithComponents/SimpleTagHelper.cs create mode 100644 src/Razor/test/testassets/SimpleMvc21/SimpleTagHelper.cs create mode 100644 src/Razor/test/testassets/SimpleMvc22/SimpleTagHelper.cs diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.CodeGeneration.targets b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.CodeGeneration.targets index 72d170a7d2..72599af998 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.CodeGeneration.targets +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.CodeGeneration.targets @@ -70,14 +70,15 @@ Copyright (c) .NET Foundation. All rights reserved. - + @@ -105,7 +106,7 @@ Copyright (c) .NET Foundation. All rights reserved. Version="$(RazorLangVersion)" Configuration="@(ResolvedRazorConfiguration)" Extensions="@(ResolvedRazorExtension)" - Assemblies="@(RazorReferencePath);$(_RazorGenerateTargetReferenceAssembly)" + Assemblies="@(RazorReferencePath)" ProjectRoot="$(MSBuildProjectDirectory)" TagHelperManifest="$(_RazorTagHelperOutputCache)"> - <_RazorGenerateTargetReferenceAssembly>@(_RazorComponentDeclarationAssembly->Metadata('FullPath')) + <_RazorComponentDeclarationAssemblyFullPath>@(_RazorComponentDeclarationAssembly->Metadata('FullPath')) 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 5aa5c6ffb0..e148904829 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 @@ -74,7 +74,8 @@ Copyright (c) .NET Foundation. All rights reserved. - ResolveRazorEmbeddedResources + ResolveRazorEmbeddedResources; + _FixupRazorReferencePathForRazorCompile; @@ -471,22 +472,33 @@ Copyright (c) .NET Foundation. All rights reserved. + - - - <_RazorGenerateTargetReferenceAssembly Condition="'$(_RazorGenerateTargetReferenceAssembly)'==''"> - @(IntermediateAssembly->Metadata('FullPath')) - + - <_RazorCompileTargetReferenceAssembly Condition="'$(_RazorCompileTargetReferenceAssembly)'==''"> - @(IntermediateAssembly->Metadata('FullPath')) - - + + + + + + + + + +