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:
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