'AdvancedInstaller in Devops - cant sync files

I have the following task in my CI build.

     - task: CmdLine@2
        displayName: Update Installer Project & Build
        inputs:
          script: |
            echo $(publishPath)
            AdvancedInstaller.com /edit $(agentMSIProject) /NewSync APPDIR "$(publishPath)" -exclude_subfolders -exclude_patterns *.pdb -existingfiles delete
            AdvancedInstaller.com /edit $(agentMSIProject) /SetOutputLocation -buildname DefaultBuild -path $(outputPath)
            AdvancedInstaller.com /build $(agentMSIProject)

Ive tried using the AdvancedInstaller@2 task directly but cant figure it out so just used my non devops build script.

I get the following error. It seems like AdvancedInstaller is not interpreting the $publishPath.

========================== Starting Command Output ===========================
"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "D:\a\_temp\ecc57176-0a2e-441e-8255-57ea9bf8ad19.cmd""
D:\a\1\a\agentPublish
Some files and/or folders are referenced from other components and were not deleted.
 
The source folder "D:\a\agentPublish" of the synchronized folder "APPDIR" is missing from disk. You need to either recreate the source folder path or reset the synchronization from the "Folder Properties" dialog, in "Synchronize" tab. 
 

Did I miss something here?

Thanks

== Update

My build script is now like :

      - task: AdvancedInstallerTool@1
        displayName: Install Advanced Installer
        inputs:
          advinstVersion: 18.3
          advinstEnableCom: true
          advinstLicense: $(AdvancedInstallerLicenseKey)

      - task: PowerShell@2
        displayName: Update Installer Project
        inputs:
          targetType: inline
          script:
            AdvancedInstaller.com /edit $(agentProject) /DelShortcut -name "Agent" -dir DesktopFolder
            AdvancedInstaller.com /edit $(agentProject) /DelShortcut -name "Agent" -dir SHORTCUTDIR
            AdvancedInstaller.com /edit $(agentProject) /DelShortcut -name "Check for Updates" -dir SHORTCUTDIR
            AdvancedInstaller.com /edit $(agentProject) /DelShortcut -name "Uninstall [|ProductName] [|ProductVersion]" -dir SHORTCUTDIR
            AdvancedInstaller.com /edit $(agentProject) /UpdatePathVariable -name PublishSource -value "$(publishPath)" -valuetype Folder
            AdvancedInstaller.com /edit $(agentProject) /NewSync APPDIR "$(publishPath)" -exclude_subfolders -exclude_patterns *.pdb
            AdvancedInstaller.com /edit $(agentProject) /NewShortcut -name "Agent" -dir DesktopFolder -target APPDIR\Agent.exe -runasadmin -wkdir APPDIR -icon "$(installerIcon)"
            AdvancedInstaller.com /edit $(agentProject) /NewShortcut -name "Agent" -dir SHORTCUTDIR -target APPDIR\Agent.exe -runasadmin -wkdir APPDIR -icon "$(installerIcon)"
            AdvancedInstaller.com /edit $(agentProject) /NewShortcut -name "Check for Updates" -dir SHORTCUTDIR -target APPDIR/Updater.exe -icon "$(updaterIcon)" -wkdir APPDIR
            AdvancedInstaller.com /edit $(agentProject) /NewShortcut -name "Uninstall [|ProductName] [|ProductVersion]" -dir SHORTCUTDIR -target [SystemFolder]msiexec.exe -icon "$(uninstallerIcon)" -arg "/x [ProductCode]"
            AdvancedInstaller.com /edit $(agentProject) /SetOutputLocation -buildname DefaultBuild -path $(outputPath)
            AdvancedInstaller.com /build $(agentProject)

Im using a Path variable for the APPDIR sync folder.

Now I get this error:

Unknown parameter: -name. Maybe you should use instead: -name. 
Unknown parameter: -dir. Maybe you should use instead: -dir. 
Unknown parameter: -name. Maybe you should use instead: -name. 
Unknown parameter: -dir. Maybe you should use instead: -dir. 
Unknown parameter: -name. Maybe you should use instead: -name. 
Unknown parameter: -dir. Maybe you should use instead: -dir. 
Unknown parameter: -name. Maybe you should use instead: -name. 
Unknown parameter: -value. Maybe you should use instead: -name. 
Unknown parameter: -valuetype. 
Unknown parameter: -exclude_subfolders. 
Unknown parameter: -exclude_patterns. 
Unknown parameter: -name. Maybe you should use instead: -name. 
Unknown parameter: -dir. Maybe you should use instead: -dir. 
Unknown parameter: -target. 
Unknown parameter: -runasadmin. 
Unknown parameter: -wkdir. Maybe you should use instead: -dir. 
Unknown parameter: -icon. 
Unknown parameter: -name. Maybe you should use instead: -name. 
Unknown parameter: -dir. Maybe you should use instead: -dir. 
Unknown parameter: -target. 
Unknown parameter: -runasadmin. 
Unknown parameter: -wkdir. Maybe you should use instead: -dir. 
Unknown parameter: -icon. 
Unknown parameter: -name. Maybe you should use instead: -name. 
Unknown parameter: -dir. Maybe you should use instead: -dir. 
Unknown parameter: -target. 
Unknown parameter: -icon. 
Unknown parameter: -wkdir. Maybe you should use instead: -dir. 
Unknown parameter: -name. Maybe you should use instead: -name. 
Unknown parameter: -dir. Maybe you should use instead: -dir. 
Unknown parameter: -target. 
Unknown parameter: -icon. 
Unknown parameter: -arg. Maybe you should use instead: -name. 



Solution 1:[1]

It seems the old synchronized resources are referenced in your setup project by other installation entities (maybe services, assemblies, shortcuts, custom action entries, etc) and when the /NewSync command executes it fails to delete those old synced resources.

The correct approach would be to delete/remove all the installation entities that refers synced resources before calling the /NewSync command.

Hope this is useful.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 herman.smn