首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MSBuild /p:GenerateAppInstallerFile使用旧方案创建.appinstaller文件

MSBuild /p:GenerateAppInstallerFile使用旧方案创建.appinstaller文件
EN

Stack Overflow用户
提问于 2021-06-24 18:08:24
回答 1查看 62关注 0票数 1

在我的构建管道(Azure DevOps)中,我添加了/p:GenerateAppInstallerFile,以便自动为.appinstaller部署创建一个MSIX文件。

该文件由MS代理生成,在最新的Windows版本上运行:

代码语言:javascript
复制
  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'

但是生成的文件使用了一个过时的模式:

代码语言:javascript
复制
xmlns="http://schemas.microsoft.com/appx/appinstaller/2017/2"

此格式不支持我要使用的自动更新功能。

我需要的是新的模式:

代码语言:javascript
复制
xmlns="http://schemas.microsoft.com/appx/appinstaller/2018"

如何让MS代理生成最新格式的文件?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-06-29 22:40:55

我最终创建了一个修改生成的文件的任务:

代码语言:javascript
复制
  - 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
  }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68113722

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档