Guilherme Marques
Guilherme Marques

Reputation: 59

Azure Devops Pipeline - Use Microsoft Visual Studio Installer Projects

I'm using Azure devops with the VM = vmImage: 'windows-2019' and I would like to know how to generate an MSI file from my vdproj.

In my local visual studio I have the extension "Microsoft Visual Studio Installer Projects" installed and it works fine. But in the VS2019 of the hosted agent from Azure pipeline I dont have, and I can't generate the msi as an artifact.

I've tried to run by devenv.exe cmd but as I dont have the extension it didnt work.

Is there any way to generate msi files from azure pipeline? I've tried different ways, some custom tasks but it didnt work.

Or can I change my setups to another type of project that the MsBuild reconigze?

My error:

The project file "xxx.vdproj" is not supported by MSBuild and cannot be built.

Cheers.

Upvotes: 2

Views: 2234

Answers (3)

Kishan Vaishnani
Kishan Vaishnani

Reputation: 192

I was facing the same issues but after much research, I figured out how to build the installer project in the Azure DevOps pipeline. Please give it a try.

trigger:
  branches:
    include:
    - 'release'

pool:
  vmImage: 'windows-2022'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'
  devCmd: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\devenv.com'
  disableToolPath: '$(devCmd)\CommonExtensions\Microsoft\VSI\DisableOutOfProcBuild'
  setupExePath: '$(Build.ArtifactStagingDirectory)\SampleProject\Release\Setup.msi'

steps:

# Install NuGet
- task: NuGetToolInstaller@1
  displayName: 'Use NuGet 5.x'

# Use the required .NET SDK

- task: UseDotNet@2
  displayName: "Use dotnet sdk 8.x"
  inputs:
    packageType: "sdk"
    version: "8.x"
  
# Set the .NET Framework 4.8 Path
- task: CmdLine@2
  displayName: "Set NETFX 4.8 Path"
  inputs:
    script: 'set PATH=%path%;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\'

# Restore NuGet packages
- task: NuGetCommand@2
  displayName: "Restore nuget packages"
  inputs:
    restoreSolution: "$(solution)"

# https://github.com/it3xl/MSBuild-DevEnv-Build-Server-Workarounds/issues/1#issuecomment-525435637
- task: BatchScript@1
  displayName: Enable .vdproj Builds
  inputs:
    filename: '"$(disableToolPath)\DisableOutOfProcBuild.exe"'
    workingFolder: '"$(disableToolPath)"'

- script: '"$(devCmd)" $(System.DefaultWorkingDirectory)\SampleProject.sln /Build "Release" /Project $(System.DefaultWorkingDirectory)\SetupProject\Setup.vdproj'
  displayName: Build Installer
#  timeoutInMinutes: 15  # Increase if necessary        

# Copy the setup files to the artifact staging directory
- task: CopyFiles@2
  displayName: 'Copy MIS files'
  inputs:
    contents: 'SetupProject/$(buildConfiguration)/**'
    targetFolder: '$(Build.ArtifactStagingDirectory)'

# Distribution
- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifacts'
  inputs:
    pathToPublish: '$(Build.ArtifactStagingDirectory)'
    artifactName: 'SetupArtifacts'
    publishLocation: 'Container'

Upvotes: 0

Peter Drier
Peter Drier

Reputation: 1397

Component.VSInstallerProjects v: 0.9.9 is now installed on the Microsoft-hosted agent 2019.

Upvotes: 1

Hugh Lin
Hugh Lin

Reputation: 19391

The project file "xxx.vdproj" is not supported by MSBuild and cannot be built.

For this issue ,that because Visual Studio Installer Projects extension is not installed on the Hosted agent. You can view this link for a list of software installed on Microsoft-hosted agent2019.

As a work around , you have to configure your own build agent to run the build.

Make sure the VS Installer Projects extension is installed on your own build agent and then you can build the setup project either use command line task with "devenv" or use the "Build VS Installer" task.

To Build .msi file by VS installer project, you can use Build VS Installer task in marketplace.

You can specify to build .sln or .vdproj to generate .msi file(s) in Task-mode option.

enter image description here

Here are the similar cases:1,2 , you can refer to .

Upvotes: 1

Related Questions