question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.NET Core MSBuild is missing the LC task

See original GitHub issue

From @livarcocc on Monday, April 24, 2017 5:08:10 PM

From @alienisty on April 24, 2017 1:58

Steps to reproduce

Just create a project with a licenses.licx file definition and build the project with

dotnet build project.csproj

Expected behavior

The project builds and the license information are compiled in the binaries

Actual behavior

The following error is raised:

C:\Program Files\dotnet\sdk\1.0.3\Microsoft.Common.CurrentVersion.targets(2977,5): error MSB4062: The “Microsoft.Build.Tasks.LC” task could not be loaded from the assembly Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. Confirm that the <UsingTask> decl aration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. 0 Warning(s) 1 Error(s)

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.3)

Product Information: Version: 1.0.3 Commit SHA-1 hash: 37224c9917

Runtime Environment: OS Name: Windows OS Version: 6.3.9600 OS Platform: Windows RID: win81-x64 Base Path: C:\Program Files\dotnet\sdk\1.0.3

Copied from original issue: dotnet/cli#6389

Copied from original issue: microsoft/msbuild#2006

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:35 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
weltkantecommented, Apr 2, 2021

There already is no (working) licensing in .NET Core, some fractions of the old infrastructure remain working, but as a whole it does not work even now. Its a longstanding open issue. Considering its not even officially possible yet to develop custom controls its not a major issue.

The deprecation of BF will be much more catastrophic to the Clipboard and Drag and Drop systems though if/when it gets deprecated there as well, these require it and I’m not aware of a plan for a replacement. (Though maybe there are internal plans not made public yet?)

1reaction
EamonHethertoncommented, Aug 12, 2020

For anyone is the same boat I am currently in with migrating older code containing components that use the license.licx runtime licensing model towards dotnet core and wanting to use “dotnet build” here is the workaround that I am using.

Caveat; it works for me, YMMV.

  1. Ensure your licenses.licx file is included in your project with BuildAction “EmbeddedResource”
  2. Build project using visual studio or msbuild
  3. Find “[projectname].exe.licenses” file in obj folder and copy to root of exe project and include as EmbeddedResource
  4. Change licenses.licx to BuildAction “None” to avoid “error MSB4062: The “Microsoft.Build.Tasks.LC” task could not be loaded”

now you can build using dotnet build without getting “error MSB4062: The “Microsoft.Build.Tasks.LC” task could not be loaded from the assembly Microsoft.Build.Tasks.Core” and with proper runtime licences embedded.

This may become tedious if you are regularly changing the components/versions etc. and your licenses.licx files changes but for me the components using the licenses.licx model have not changed in a number of years so neither has my licenses.licx file and I don’t expect it to change anytime soon, more likely they’ll eventually be replaced by something that does not need licenses.licx entries.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not run the "LC" task because MSBuild ...
Based on experience,. You can try to add the following code in the csproj file: (unload the project, then double-click the project to...
Read more >
LC Task - MSBuild
Learn how MSBuild uses the LC task to wrap LC.exe, which generates a .license file from a .licx file.
Read more >
Net Core/MSBuild Tooling not finding right version
Received this error when build a .sfproj that contains .net core 3.1 projects. ... NET Core SDK requires at least version 16.7.0 of...
Read more >
LC Task in .NET Core Projects
NET Core, the LC task is not supported or fails. This article explains how to compile the licenses successfully.
Read more >
Using Rider under Windows without Visual Studio
NET Core SDK or Visual Studio installed, we expect JetBrains Rider to start working without taking any further configuration steps.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found