在我的构建管道(Azure DevOps)中,我添加了/p:GenerateAppInstallerFile,以便自动为.appinstaller部署创建一个MSIX文件。
该文件由MS代理生成,在最新的Windows版本上运行:
pool:
# need a windows agent
vmImage: 'windows-latest'
- task: MSBuild@1
displayName: MSBuild
inputs:
solution: '**/*.sln'
platform: 'x64'
configuration: 'Release'
msbuildArguments: '/restore
/p:GenerateAppInstallerFile=true'但是生成的文件使用了一个过时的模式:
xmlns="http://schemas.microsoft.com/appx/appinstaller/2017/2"此格式不支持我要使用的自动更新功能。
我需要的是新的模式:
xmlns="http://schemas.microsoft.com/appx/appinstaller/2018"如何让MS代理生成最新格式的文件?
发布于 2021-06-29 22:40:55
我最终创建了一个修改生成的文件的任务:
- task: PowerShell@2
displayName: 'Modify generated .appinstaller file'
inputs:
targetType: 'inline'
script: |
$newSchema = "http://schemas.microsoft.com/appx/appinstaller/2018"
$localFilePath = "$(installerBuildOutputPath)\${{ parameters.installerProjectName}}.appinstaller"
Write-Host "Loading file as text: " $localFilePath
$fileContent = Get-Content $localFilePath
# First replace the schema with the newest one. Using normal text replace here since Xml doc methods gave exceptions.
# using text replace is easier than manipulating xml nodes, but causes problems with indentation...
$fileContent = $fileContent.Replace("http://schemas.microsoft.com/appx/appinstaller/2017/2", $newSchema);
$fileContent = $fileContent.Replace(
'HoursBetweenUpdateChecks="0"',
'HoursBetweenUpdateChecks="0" ShowPrompt="true" UpdateBlocksActivation="true"');
$fileContent = $fileContent.Replace(
'</UpdateSettings>',
'<ForceUpdateFromAnyVersion>true</ForceUpdateFromAnyVersion>
</UpdateSettings>');
Write-Host "New file contents: $fileContent";
if($fileContent -like "*UpdateBlocksActivation*" -and $fileContent -like "*$newSchema*")
{
Write-Host "Replaced namespace (xmlns) with newest schema version. Modified UpdateSettings."
$fileContent | Set-Content $localFilePath
}
else
{
Write-Host "Text replacement failed."
exit 1
}https://stackoverflow.com/questions/68113722
复制相似问题