Page 1 of 1

Embedding license when building on Azure DevOps

Posted: Mon 20 Dec 2021 12:38
by Xor
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.

Re: Embedding license when building on Azure DevOps

Posted: Mon 20 Dec 2021 18:32
by Shalex
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 .

Re: Embedding license when building on Azure DevOps

Posted: Thu 13 Jan 2022 09:09
by Xor
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.