TFS中Advanced Installer更新配置项目:从安装程序输出更新版本号失败
Let's break down how to fix that failing second Advanced Installer task in your TFS pipeline. Here's what we know so far:
- Your first task builds the installer from publish artifacts without issues
- The second task is supposed to pull that installer, extract its version number, and generate
updater.txt—but it's failing. You can get this working manually locally, so the issue is likely tied to the TFS pipeline setup.
1. First: Verify File Access & Task Dependencies
Most often, the second task can't find the installer the first one generated. Let's check these basics:
- Ensure task dependency: In TFS, edit your pipeline and make sure the second task is set to run only after the first task succeeds. You can find this under the task's "Control Options"—check "Run this task only if all previous tasks have succeeded".
- Double-check file paths: Confirm the path you're using in the second task matches exactly where the first task outputs the installer. For example, if the first task drops
Setup.exeinto$(Build.ArtifactStagingDirectory)\MyApp, the second task needs to point to that exact location. - Check agent permissions: The TFS build agent service account needs read access to the installer file path. If the agent runs under a restricted account, it might not be able to access the artifact staging directory.
2. Fix Version Number Extraction
You have two solid ways to pull the installer version into your pipeline:
Option 1: Pass the Version from the First Task
Instead of having the second task re-extract the version, capture it in the first task and pass it via a pipeline variable:
- Edit your first Advanced Installer task, go to the "Advanced" section, and add this command-line argument:
/GetVersion $(Build.ArtifactStagingDirectory)\Setup.exe -outvar AI_SetupVersion - This stores the installer version in a variable named
AI_SetupVersionthat the second task can use directly. For example, in a PowerShell task to generateupdater.txt, you'd write:"LatestVersion=$(AI_SetupVersion)" | Out-File "$(Build.ArtifactStagingDirectory)\updater.txt" -Encoding UTF8
Option 2: Extract Version in the Second Task (with Command Line)
If you need to do the extraction in the second task, use Advanced Installer's command-line tool directly. Add a "Command Line" task before your Advanced Installer task (or integrate it into the task) with this script:
"C:\Program Files (x86)\Caphyon\Advanced Installer\<YOUR_VERSION>\bin\x86\AdvancedInstaller.com" /GetVersion "$(Build.ArtifactStagingDirectory)\Setup.exe" > "$(Build.ArtifactStagingDirectory)\version.txt"
Then read that version file to build your updater.txt. Make sure to replace <YOUR_VERSION> with the actual Advanced Installer version on your build agent.
3. Dig Into the Build Logs
Don't skip this step—TFS logs will tell you exactly why the task is failing:
- Go to your failed build in TFS, click "View Logs", and navigate to the second Advanced Installer task.
- Look for error messages like "File not found", "Access denied", or "Failed to retrieve version". These will point you straight to the root cause (e.g., wrong path, missing permissions).
4. Test the Agent Environment Locally
Since it works on your machine, test the same steps on the TFS build agent server:
- Log into the agent server using the same account the build agent runs under.
- Manually run the commands the second task is executing (e.g., extract the version, generate the text file).
- This will reveal if the agent is missing dependencies, has an outdated Advanced Installer version, or has permission issues that don't show up in your local environment.
内容的提问来源于stack exchange,提问作者Jensen

