I have upgraded my application to asp.net core 2.0 and now my taghelpers are not rendering. I have made no change in my code. Below is my _ViewImport.cshtml and labeltaghelper.cs. Also while doing build I am getting warning
'Microsoft.AspNet.Mvc.TagHelpers 6.0.0-rc1-final' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'
_ViewImport.cshtml
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, IntegraPay.RegistrationApplication
LabelTagHelper.cs
using IntegraPay.Domain.SObjects;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Razor.TagHelpers;
namespace IntegraPay.RegistrationApplication.TagHelpers
{
[HtmlTargetElement("label", Attributes = FieldContentMetaData)]
public class LabelTagHelper : TagHelper
{
private const string FieldContentMetaData = "tag-FieldMetaData";
[HtmlAttributeName(FieldContentMetaData)]
public WebFormFieldContent FieldContent { get; set; }
private TagBuilder AnchorBuilder { get; set; } = new TagBuilder("a");
private TagBuilder asteriskBuilder { get; set; } = new TagBuilder("span");
private void CreateAsteriskIcon()
{
asteriskBuilder.Attributes.Add("class", "asteriskStyle");
asteriskBuilder.InnerHtml.Append("*");
}
public override void Process(TagHelperContext context, TagHelperOutput output)
{
if (FieldContent.Required__c)
{
CreateAsteriskIcon();
output.PreElement.AppendHtml(asteriskBuilder);
}
if (FieldContent.Visible__c)
{
output.Content.SetHtmlContent(FieldContent.Label_Override__c);
if (!string.IsNullOrEmpty(FieldContent.Field_Description__c))
{
GenerateAnchorToolTipTag();
output.Content.AppendHtml(" ");
output.Content.AppendHtml(AnchorBuilder);
}
}
else
{
output.Attributes.Add("class", "ControlIsVisible");
}
base.Process(context, output);
}
private void GenerateAnchorToolTipTag()
{
if (!string.IsNullOrEmpty(FieldContent.Field_Description__c))
{
AnchorBuilder.Attributes.Add("data-toggle", "tooltip");
AnchorBuilder.Attributes.Add("data-placement", "right");
AnchorBuilder.Attributes.Add("data-original-title", FieldContent.Field_Description__c);
string iclass = "ip fa fa-question-circle-o";
AnchorBuilder.InnerHtml.AppendHtml($"<i class='{iclass}' aria-hidden='true'></i>");
}
}
}
}
csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<DebugType>portable</DebugType>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>Integrapay.RegistrationApplication</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>Integrapay.RegistrationApplication</PackageId>
<RuntimeFrameworkVersion>1.1.2</RuntimeFrameworkVersion>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
<SignAssembly>False</SignAssembly>
</PropertyGroup>
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
<ItemGroup>
<DocFile Include="bin\$(Configuration)\$(TargetFramework)\Integrapay.RegistrationApplication.xml" />
</ItemGroup>
<Copy SourceFiles="@(DocFile)" DestinationFolder="$(PublishDir)" SkipUnchangedFiles="false" />
</Target>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\netcoreapp1.1\Integrapay.RegistrationApplication.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\Release\netcoreapp1.1\Integrapay.RegistrationApplication.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Remove="bower_components\bootstrap-fileinput\**" />
<Content Remove="bower_components\bootstrap-fileinput\**" />
<EmbeddedResource Remove="bower_components\bootstrap-fileinput\**" />
<None Remove="bower_components\bootstrap-fileinput\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Controllers\LoginController.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="wwwroot\docs\ui\custom.css" />
<Content Include="wwwroot\docs\ui\index.html" />
</ItemGroup>
<ItemGroup>
<Folder Include="bower_components\" />
<Folder Include="wwwroot\css\" />
</ItemGroup>
<ItemGroup>
<None Update="wwwroot\**\*;Views\**\*;bin\Debug\netcoreapp1.1\Integrapay.RegistrationApplication.xml">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.Mvc.TagHelpers" Version="6.0.0-rc1-final" />
<!--<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />-->
<PackageReference Include="DeveloperForce.Force" Version="1.3.2" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.DataAnnotations" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration.Tools" Version="1.0.0-preview2-final" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.5" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.0" />
<PackageReference Include="Microsoft.Framework.Configuration" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.NETCore.Portable.Compatibility" Version="1.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.1" />
<PackageReference Include="MailKit" Version="2.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.2" />
<PackageReference Include="Swashbuckle" Version="5.6.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.1.0" />
<PackageReference Include="System.Runtime" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.NETCore.App" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\IntegraPay.Domain\IntegraPay.Domain.csproj" />
</ItemGroup>
</Project>
PackageTargetFallback
node and property toAssetTargetFallback
as part of upgrading to 2.0. See docs.microsoft.com/en-us/aspnet/core/migration/1x-to-2x/… – Cake or Death