Can't build a .NET Core project using dotnet publish when using RO/DA class libraries

Hello,

So I just hit a wall in a project I am writing. It’s an AWS Lambda function, in .NET Core 2.1, that is using DataAbstract to connect to the database. I got it to a point where everything was working perfectly in my dev environment, but when I tried to publish the serverless app to AWS, the build process failed with this error:

.. invoking 'dotnet publish', working folder ...
... Disabling compilation context to reduce package size. If compilation context is needed pass in the "/p:PreserveCompilationContext=false" switch.
... publish: Microsoft (R) Build Engine version 16.0.450+ga8dc7f1d34 for .NET Core
... publish: Copyright (C) Microsoft Corporation. All rights reserved.
... ... publish: C:\Program Files\dotnet\sdk\2.1.602\Microsoft.Common.CurrentVersion.targets(3164,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> declaration 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. 
Failed to create application package

This is related to this MSBuild issue which basically means that we can’t build .NET Core projects that require a licenses.licx file (as RO does), using dotnet.exe.

I know I can use MSBuild and MSDeploy as suggested in the issue’s description, but trying to replicate manually everything the AWS Lambda Tools do, is far more work for me than maybe other options (such as creating an Http API method to access the data and call that from the Lambda function).

I’m not sure there is anything than can be done in this case, so I’m just reporting this problem here, as it is not possible right now to build any .NET Core 2.1 project that uses RO/DA using the MSBuild version that dotnet.exe uses. This problem might be solved when .NET Core 3.0 comes out later this year.

In the meantime, I’ll look into HttpApi and remove the RO Client libraries from the lambda functions, :expressionless:.

Arturo.

For the record - it is not just any RO/DA project. It is any .NET Core project that uses the licensing.licx licensing model

Before you start rewriting stuff (note thast HttpAPI won’t provide you easy access to DA LINQ) let’s consider some other options (see PM)

Solution is to to build licenses into a separate assembly and referencing that assembly as a binary (so dotnet publish won’t have to call LC):

  1. Create a new Class Library project
  2. Add there the .licx file
  3. Add there a dummy class
  4. Build the assembly
  5. In the main app reference that assembly
  6. Call typeOf(that dummy class) during the app startup to ensure that the assembly is loaded
  7. DO NOT (!!!) put the built on the step [4] assembly into any public repo

This worked perfectly! It solved my problem and saved me a huge amount of work, :blush: . Thank you! :+1:

Arturo.