P.Brian.Mackey
P.Brian.Mackey

Reputation: 44275

LC.exe could not be run

On compilation I receive error for LC.EXE

The specified task executable "LC.exe" could not be run. The filename or extension is too long

This error occurs when I compile my unit test project. Of the google tricks I've seen, nothing has worked.

This started today. There's hardly anything in source control history. The changes all have to do with AssemblyInfo.cs where a 3rd party utility increments our version #'s.

UPDATE
Looking out my output window the command line call to LC.EXE is HUGE

CompileLicxFiles:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\LC.exe /target:BuildAll.Tests.dll /complist:Properties\licenses.licx /outdir:obj\Debug\ /i:C:\

There's 100's of /i params...

Upvotes: 20

Views: 21770

Answers (7)

Daniel Botero Correa
Daniel Botero Correa

Reputation: 586

I had the same issue, I added this code into my project and it worked.

<Target Name="WorkaroundMSBuild2836" BeforeTargets="CompileLicxFiles">
   <!-- Work around https://github.com/Microsoft/msbuild/issues/2836 by
        temporarily setting TargetFrameworkVersion to a version high
        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>

For further information read this post

Upvotes: 0

Alex Caranha
Alex Caranha

Reputation: 191

I changed the value of the property Build Action from EmbeddedResource to None on the file licenses.licx. It solved the problem.

Upvotes: 18

Michael Henasey
Michael Henasey

Reputation: 11

I used the command-line utility "Subst" as mentioned in this blog post to resolve my issue with LC.exe.

  1. Turn on Normal or higher Verbosity for your build.
  2. In the Output window, examine the line where the LC task is being executed. Notice there will be many /i parameters with paths to other binaries.
  3. Find one or more paths that you can use "Subst" to help shorten the path to help reduce the total length of all parameters passed to "LC.exe".
  4. Next, open the problem project's properties window in Visual Studio and select the References tab and then add the new drives you defined with Subst.

Build the project.

Remember, Subst does not persist through reboot.

Upvotes: 0

gbdev
gbdev

Reputation: 1

I had a bad problem with the file LC.exe, everything was due to the fact that the components I used were in a network drive (G :) and from that position I could never compile the executable. I finally solved by adding the IP address of the network drive between sites intranet reliable in the internet options.

Upvotes: 0

zchpit
zchpit

Reputation: 3121

There is MS Support workaround:

when you build the project , delete the Licence file from the project everytime you get this error , just delete the licence file

https://connect.microsoft.com/VisualStudio/feedback/details/779433/lc-exe-task-command-line-too-long

Upvotes: 16

Mithun
Mithun

Reputation: 1

I had a problem today, and it got resolved when I changed the path of the reference to a less longer path. For example, I initially put it in mydocuments\user\...\...\... But when I changed the path to c:\dlls\, it worked like a charm. Hope that helps.

Upvotes: 0

Boas Enkler
Boas Enkler

Reputation: 12557

had same problem. For the Lc.exe a command line is generated this is limitied up to around 32k chars. In this command normally all references are written with theit fullpath.

so if you have many references you can get into trouble.

There are some things you can do: - Remove unused references - Make sure that you don't reference indirect depdencies. Use instead the hint path you can define for the assemblies. - Shorten the path in with the references are placed - You could create a virtual drive to put the refs there to get the shorted possible reference path (eg. Z:\my.dll)

Upvotes: 2

Related Questions