Embedding license when building on Azure DevOps

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
Xor
Posts: 2
Joined: Mon 20 Dec 2021 12:28

Embedding license when building on Azure DevOps

Post by Xor » Mon 20 Dec 2021 12:38

Hello,

I'm trying to build my application on Azure DevOps hosted agents and seem to have some issues with embedding the license. Since build agent are created each time build runs it can't use license.licx file and license installed on a system.
Instead, I compiled license on dev machine, got compiled *.licenses files and embedded them instead.
This should work as that *.licenses files are one actually embedded even when you use license.licx file, and it works for the other licensed component in the project, but not for dotConnect for Postgres. Compiled app fails with error "License not found".

I wonder is there a way to compile project with proper license in this manner, I mean without installing license on build agents? Where can I find any info about it?

Thanks in advance.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Embedding license when building on Azure DevOps

Post by Shalex » Mon 20 Dec 2021 18:32

Xor wrote: Mon 20 Dec 2021 12:38 Since build agent are created each time build runs it can't use license.licx file and license installed on a system.
If you set up a pipeline for compiling your source code from repository on a build server periodically or even after every commit, you should add a step to your pipeline for installing the provider on the build server for copying Devart.* assemblies, registering provider build action, enabling automatic generation of .NET Framework license resource from provider entry in licenses.licx. For example, the corresponding step in Azure DevOps Pipeline can be the following one if you copied the provider installation to the root folder of your repository:

Code: Select all

- task: CmdLine@2
  inputs:
    script: '$(Build.SourcesDirectory)\dcpostgresql.exe /TYPE=FULL /VERYSILENT'
More information about the command line installation keys is available at https://www.devart.com/dotconnect/postg ... tion.html .

Xor
Posts: 2
Joined: Mon 20 Dec 2021 12:28

Re: Embedding license when building on Azure DevOps

Post by Xor » Thu 13 Jan 2022 09:09

Thanks for the info, Shalex.

I actually made it to work with the precompiled dll.licenses and exe.licenses files. The reason of error I was getting was the following:
  • I placed *.licenses files in the same place as *.licx, i.e. the Properties folder.
  • When the project *.licx is compiled, lc.exe adds an embedded resource with name of "AssemblyName.(dll|exe).licenses".
  • But, if add the already pre-compiled *.licenses to the Properties folder and make it the embedded resource, it will get name "AssemblyName.Properties.(dll|exe).licenses".
  • Not sure why Devart didn't get it (the other licensed component I use were getting license correctly).
The fix was to match the new resource name with the original. The easiest way is to add a logical name to the embedded resource and explicitly name it in the compiled assembly like that:

Code: Select all

<EmbeddedResource Include="Properties\exe.licenses">
	<LogicalName>AssemblyName.exe.licenses</LogicalName>
</EmbeddedLicense>
After that everything is working as it should.

Post Reply