Search code examples
azurebatch-fileazure-devopsyamlautoit

How to register AutoIT COM DLL while running from azure


I am trying to use AutoIT in my automated tests for the project. Locally I am able to register the COM Library using regsvr32 but when I try to do the same from my azure pipeline, the script runs continuously. I have my azure pipeline yml as following:

      - job: Tests
        displayName: Automated Tests
        pool:
         vmImage: "windows-latest"
        steps: 

      - task: NuGetToolInstaller@1

      - task: DotNetCoreCLI@2
        displayName: Restore Packages
        inputs:
          command: 'restore'
          projects: 'Free.Automation/Free.Automation.csproj'
          feedsToUse: 'config'
          nugetConfigPath: 'Free.Automation/nuget.config'
      
      - task: BatchScript@1
        displayName: Register AutoIT
        inputs:
          filename: 'Free.Automation/autoit.bat'

      - task: MSBuild@1
        inputs:
          solution: "Free.Automation/Free.Automation.sln"

And this is the bat file I am using:

     cd c:\windows\system32
     regsvr32 C:\Users\%USERNAME%\.nuget\packages\autoitx.dotnet\3.3.14.5\build\AutoItX3.dll

I verified that the path of azure pipeline space is something D:\1\a\s but not sure how the directory works. Could anyone help me registering the COM lib on azure hosted pipeline space?


Solution

  • With Azure DevOps Microsoft-hosted agent, you can't get your local files directly. So if you want to use COM DLLs, you need to include them in your source code files.

    I recommend that you have a lib folder to store your DLLs in. Please make sure that your DLLs are referenced correctly as a relative path in .csproj.

    I verified that the path of azure pipeline space is something D:\1\a\s but not sure how the directory works.

    In Azure DevOps, you can use the predefined variable $(System.DefaultWorkingDirectory) to get the local path on the agent where your source code files are downloaded. That's the "azure pipeline space D:\1\a\s" you mentioned.