LC Task in .NET Core Projects
The license compiler (lc.exe) is compiling the licenses of referenced components into the resources of a created assembly. In some versions of .NET Core, the LC task is not supported or fails. This article explains how to compile the licenses successfully.

In .NET projects, licenses of referenced, licensed assemblies are compiled into the resources of the calling application assembly. For Windows Forms and WPF applications, these are the created EXE files and for web applications (both .NET 4.x and .NET Core), the licenses are embedded in the application's main DLL.
In older versions of Visual Studio 2019 (< version 16.5.4), the LC task was not part of the MSBuild process (#2006). The result was that licenses, even if the licenses.licx file is included as an embedded resource, were not compiled into the application.
This changed in newer versions of Visual Studio 2019 and Visual Studio 2019 Preview. In new versions including the most current version 16.5.4 (Visual Studio 2019) and 16.6.0 Preview 4.0 (Visual Studio 2019 Preview), the LC task is executed on compiling the application.
But unfortunately, that doesn't mean that this works. In many cases, this error is shown while compiling:
MSB6003 The specified task executable "lc.exe" could not be run. System.ComponentModel.Win32Exception (0x80004005): The filename or extension is too long
Affected are .NET Core 2.0, 3.0 and 3.1 applications in all Visual Studio 2019 versions including Preview versions. For .NET 5, this problem is solved (at least in Visual Studio 2019 Preview). So, fingers crossed for the final release of .NET 5 in November 2020 that Microsoft keeps it as is and fixes this for .NET Core applications < 5.
To workaround this error, you can add the following groups to your project file (.csproj) of your application:
<Target Name="WorkaroundMSBuild2836" BeforeTargets="CompileLicxFiles">
<PropertyGroup>
<_OriginalTargetFrameworkVersion>$(TargetFrameworkVersion)</_OriginalTargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
</Target>
<Target Name="UndoWorkaroundMSBuild2836" AfterTargets="CompileLicxFiles">
<PropertyGroup>
<TargetFrameworkVersion>$(_OriginalTargetFrameworkVersion)</TargetFrameworkVersion>
</PropertyGroup>
</Target>
In this case, temporarily, another framework target version is used for the LC task.
The table below shows the differences in various .NET Core versions and indicates whether a workaround is required or not:
Visual Studio Version | .NET Core 2.0 | .NET Core 3.0 | .NET Core 3.1 | .NET Core 5 |
---|---|---|---|---|
Visual Studio 2019 ( >= 16.5.4 ) |
✓ * | ✓ * | ✓ * | N/A |
Visual Studio 2019 Preview 4 ( >= 16.6.0 ) |
✓ * | ✓ * | ✓ * | ✓ |
* Workaround required
ASP.NET
Integrate document processing into your applications to create documents such as PDFs and MS Word documents, including client-side document editing, viewing, and electronic signatures.
- Angular
- Blazor
- React
- JavaScript
- ASP.NET MVC, ASP.NET Core, and WebForms
Related Posts
ASP.NET Core: Deploying the TX Text Control 32.0 SP2 Document Editor to Linux
To deploy the TX Text Control 32.0 SP2 Document Editor on Linux as part of an ASP.NET Core Web application, the synchronization service must be deployed separately on a Windows VM. This allows the…
ASP.NET Core: Deploying the TX Text Control Document Viewer to Azure App…
Unlike the document editor, the document viewer doesn't require a TCP synchronization service to render the document. But it also requires a backend that runs on a Windows Server instance. This…
Visual Studio 2022 and .NET 5, 6 and 7 (Preview) Support and Strategy
With the release of TX Text Control 31.0, we will fully support .NET 5, 6 and 7 (Preview) within Visual Studio 2022 including Windows Forms designer support, NuGet packages and deployment support.
2021 Wrap Up - Rethinking Documents
2021 was an exciting year for Text Control with new innovative products, features and technologies. This blog entry gives a quick overview of the last year and an outlook of what to expect in 2022.
ASP.NET Core: Deploying the TX Text Control Document Viewer to Azure App…
Unlike the document editor, the document viewer doesn't require a TCP synchronization service to render the document. But it also requires a backend that runs on a Windows Server instance. This…