【问题标题】:Build MSI in Azure DevOps using Wix Toolkit使用 Wix Toolkit 在 Azure DevOps 中构建 MSI
【发布时间】:2021-04-15 17:04:22
【问题描述】:

我有一个包含两个项目的 Visual Studio 解决方案; MyProject 和 MyProject.Installer 后者是 Wix 工具集项目。我确实从 Wix 项目中引用 MyProject,因为我不想要典型的构建输出,而是想要独立的二进制文件(请参阅管道)。

我做一个 dotnet 发布并将我想要的文件输出到 \client 相对于 MyProject.Installer wix 项目。在 Product.wxs 文件中,我引用了这些文件:

<Component Id="MyProject.exe" Guid="b1211231-2e88-4679-b2d3-879e8a3f9353">
    <File Id="MyProject.exe" Source="client\MyProject.exe" KeyPath="yes"  />
</Component>

我的 Azure DevOps 管道如下:

trigger:
- master

pool:
  vmImage: 'windows-latest'
variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'
steps:
- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'
- task: DotNetCoreCLI@2
  inputs:
    command: 'publish'
    publishWebProjects: false
    projects: '**/MyProject.csproj'
    arguments: '--output $(Build.ArtifactStagingDirectory)\client --configuration $(BuildConfiguration) --runtime win-x86 -p:PublishSingleFile=true -p:PublishTrimmed=true'
    zipAfterPublish: false
    modifyOutputPath: false
- task: MSBuild@1
  inputs:
    solution: '**/*.wixproj'
    configuration: '$(BuildConfiguration)'
    msbuildArguments: '/p:RunWixToolsOutOfProc=true'
- task: PublishBuildArtifacts@1
  displayName: 'Save artifacts'
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'

管道运行的输出(成功):

"C:\Program Files\dotnet\dotnet.exe" publish D:\a\1\s\MyProject\MyProject.csproj --output D:\a\1\a\client --configuration Release --runtime win-x86 -p:PublishSingleFile=true -p:PublishTrimmed=true

WIX(不成功):

C:\Program Files (x86)\WiX Toolset v3.11\bin\Light.exe -out D:\a\1\s\MyProject.Installer\bin\Release\nb-NO\MyProject.Installer.msi -pdbout D:\a\1\s\MyProject.Installer\bin\Release\nb-NO\MyProject.Installer.wixpdb -cultures:nb-NO -ext "C:\Program Files (x86)\WiX Toolset v3.11\bin\\WixUIExtension.dll" -loc Product.nb-NO.wxl -contentsfile obj\Release\MyProject.Installer.wixproj.BindContentsFileListnb-NO.txt -outputsfile obj\Release\MyProject.Installer.wixproj.BindOutputsFileListnb-NO.txt -builtoutputsfile obj\Release\MyProject.Installer.wixproj.BindBuiltOutputsFileListnb-NO.txt -wixprojectfile D:\a\1\s\MyProject.Installer\MyProject.Installer.wixproj obj\Release\Product.wixobj
##[error]MyProject.Installer\Product.wxs(108,0): Error LGHT0103: The system cannot find the file 'client\MyProject.exe'.

很明显,它找不到要嵌入 MSI 的文件,但我不知道如何继续。

非常感谢任何关于如何组织项目、输出和配置管道的建议。

【问题讨论】:

    标签: c# azure-devops wix windows-installer


    【解决方案1】:

    我目前的解决方案:

    由一个解决方案和两个项目组成的 Azure DevOps Git 存储库。

    • 我的客户
    • MyClient.Installer

    MyClient 项目有一个 local 发布配置文件,用于将构建输出发布到 wix 项目。这是发布配置文件:

    <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <Configuration>Release</Configuration>
        <Platform>Any CPU</Platform>
        <PublishDir>bin\Release\net5.0\publish\</PublishDir>
        <PublishProtocol>FileSystem</PublishProtocol>
        <TargetFramework>net5.0</TargetFramework>
        <SelfContained>true</SelfContained>
        <WebPublishMethod>FileSystem</WebPublishMethod>
        <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
        <LastUsedPlatform>Any CPU</LastUsedPlatform>
        <SiteUrlToLaunchAfterPublish />
        <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
        <ExcludeApp_Data>False</ExcludeApp_Data>
        <RuntimeIdentifier>win-x86</RuntimeIdentifier>
        <ProjectGuid>xxxx-xxxx-xxxx</ProjectGuid>
        <publishUrl>..\MyClient.Installer\Client</publishUrl>
        <DeleteExistingFiles>True</DeleteExistingFiles>
        <PublishSingleFile>True</PublishSingleFile>
        <PublishTrimmed>False</PublishTrimmed>
      </PropertyGroup>
    </Project>
    

    这样我可以在构建 WIX 项目时引用这些文件。

    我在 Azure DevOps 中的构建管道:

    trigger:
    - master
    
    pool:
      vmImage: 'windows-latest'
    
    variables:
      solution: '**/*.sln'
      buildPlatform: 'Any CPU'
      buildConfiguration: 'Release'
    
    steps:
    
    - task: NuGetCommand@2
      inputs:
        restoreSolution: '$(solution)'
    - task: DotNetCoreCLI@2
      inputs:
        command: 'publish'
        publishWebProjects: false
        projects: '**/MyClient.csproj'
        arguments: '--output $(Build.ArtifactStagingDirectory)\client --configuration $(BuildConfiguration) --runtime win-x86 -p:PublishSingleFile=true -p:PublishTrimmed=true'
        zipAfterPublish: false
        modifyOutputPath: false
    - task: CopyFiles@2
      inputs:
        SourceFolder: 'MyClient.Installer'
        Contents: '**'
        TargetFolder: '$(Build.ArtifactStagingDirectory)'
    - task: PublishBuildArtifacts@1
      displayName: 'Save artifacts'
      inputs:
        PathtoPublish: '$(Build.ArtifactStagingDirectory)'
        ArtifactName: 'drop'
        publishLocation: 'Container'
    

    我在这里发布文件,并将 WIX 项目也复制到工件文件夹中。现在工件包含 wix 项目和发布的输出 - 保存到 \client 文件夹,就像它在本地一样。

    有了可用的工件,我现在可以为不同的环境创建单独的 MSI,在构建 MSI 之前添加配置转换。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多