Whan building .NET Core application, you may receive one of the following error messages
Error MSB6002 The command-line for the "LC" task is too long. Command-lines longer than 32000 characters are likely to fail.
Error MSB6003 The specified task executable "lc.exe" could not be run. System.ComponentModel.Win32Exception (0x80004005): The filename or extension is too long
This is caused by a License Compiler issue and is documented on the following github pagehttps://github.com/Microsoft/msbuild/issues/2836
1. Create a backup for your project file (C# project file is *.csproj, VB project file is *.vbproj).
2. Open your project file using Visual Studio Code or any text editor.
3. Add the following code to your project between <Project> and </Project> tags
<Target Name="WorkaroundMSBuild2836" BeforeTargets="CompileLicxFiles"> <!-- Work around https://github.com/Microsoft/msbuild/issues/2836 by temporarily setting TargetFrameworkVersion to a version high enough to cause the LC task to use a response file. --> <PropertyGroup> <_OriginalTargetFrameworkVersion>$(TargetFrameworkVersion)</_OriginalTargetFrameworkVersion> <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> </PropertyGroup> </Target> <Target Name="UndoWorkaroundMSBuild2836" AfterTargets="CompileLicxFiles"> <PropertyGroup> <TargetFrameworkVersion>$(_OriginalTargetFrameworkVersion)</TargetFrameworkVersion> </PropertyGroup> </Target>
We added after the following entry and have verified success
<ItemGroup> <EmbeddedResource Include="licenses.licx" /> </ItemGroup>