How to create .msi installer with WIX in Azure Devops? - azure-devops

I am trying to create a .msi installer package with wix for my dektop app in azure devops using yaml scripting. Below is the msbuild task created for the same:
- task: MSBuild#1
inputs:
solution: '**/*.wixproj'
# platform: 'Any CPU'
configuration: 'Release'
msbuildArguments: '/p:Configuration=Release/p:ProductCode=${product_code} /p:UpgradeCode=${upgrade_code}/t:Clean;Rebuild'
clean: true
Below is the error i'm getting during the pipeline build:
Error MSB3441: Cannot get assembly name for "..\MyProject\bin\Release\MyProject.exe". Could not load file or assembly 'MyProject.exe' or one of its dependencies. The system cannot find the path specified.
Thanks in advance.

We had this problem too. Our solution was to remove the Installer project from the Solution file, continue building the other projects in the solution using the standard MSBuild task and then add script tasks to the pipeline to generate the MSI:
pool:
vmImage: windows-latest
steps:
- script: .\Tools\Wix\candle.exe -nologo Foobar.wxs -out Foobar.wixobj -ext WixUIExtension
displayName: 'Compile Wix file'
- script: .\Tools\Wix\light.exe -nologo Foobar.wixobj -out Foobar.msi -ext WixUIExtension
displayName: 'Create MSI file'
Note that our build is based on the windows-latest image which includes WiX Toolset; see the list of all included tools here.

Related

Azure pipeline for Azure Function does not find project

I've got a build pipe for an Azure Function using .Net Core 3.1.x. All the steps until the publishing are doing fine. I can get the publish step working by using script, but not through the yaml task. What am I missing?
Script (works)
- script: dotnet publish --configuration Release .\af-process-mds-vehicle-output-to-deviation\af-process-mds-vehicle-output-to-deviation.csproj
Task (does not work)
- task: DotNetCoreCLI#2
displayName: 'Publish Project'
inputs:
command: 'publish'
configuration: 'Release'
projects: '.\af-process-mds-vehicle-output-to-deviation\af-process-mds-vehicle-output-to-deviation.csproj'
zipAfterPublish: true
It doesn't find the project.
Here's the error message.
2021-10-29T05:21:44.3024816Z ##[section]Starting: dotnet publish
2021-10-29T05:21:44.3150367Z ==============================================================================
2021-10-29T05:21:44.3150726Z Task : .NET Core
2021-10-29T05:21:44.3151190Z Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
2021-10-29T05:21:44.3151475Z Version : 2.187.0
2021-10-29T05:21:44.3151733Z Author : Microsoft Corporation
2021-10-29T05:21:44.3152035Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
2021-10-29T05:21:44.3152373Z ==============================================================================
2021-10-29T05:21:44.7797987Z [command]C:\Windows\system32\chcp.com 65001
2021-10-29T05:21:44.7903026Z Active code page: 65001
2021-10-29T05:21:44.7927221Z Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
2021-10-29T05:21:44.8938257Z ##[error]No web project was found in the repository. Web projects are identified by presence of either a web.config file, wwwroot folder in the directory, or by the usage of Microsoft.Net.Web.Sdk in your project file. You can set Publish web projects property to false (publishWebProjects: false in yml) if your project doesn't follow this convention or if you want to publish projects other than web projects.
2021-10-29T05:21:44.9001249Z Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://learn.microsoft.com/en-us/dotnet/core/tools/ and https://learn.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
2021-10-29T05:21:44.9003648Z ##[error]Project file(s) matching the specified pattern were not found.
2021-10-29T05:21:44.9182124Z ##[section]Finishing: dotnet publish
After the tips from the answer I got the pipe working. Here's the full working pipe. (Still don't know why it didn't work earlier.)
Working pipe:
name : af-vehicle-sync-to-deviation
## if there is a change is the deviation folder for the main branch. Then trigger.
trigger:
branches:
include:
- main
paths:
include:
- af-process-mds-vehicle-output-to-deviation/*
pool:
vmImage: 'windows-latest'
variables:
buildConfiguration: 'Release'
SolutionPath: '**\*.sln'
stages:
- stage: Build
displayName: Build solution
jobs:
- job: Build
displayName: Build and publish solution
steps:
- checkout: self
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: $(SolutionPath)
- task: UseDotNet#2
inputs:
packageType: 'sdk'
version: '3.1.x'
displayName: 'Use .NET Core SDK 3.1.x'
- task: DotNetCoreCLI#2
inputs:
command: 'build'
configuration: $(buildConfiguration)
projects: '$(SolutionPath)'
displayName: 'Build solution'
- task: DotNetCoreCLI#2
displayName: 'Publish Project'
inputs:
command: 'publish'
configuration: 'Release'
projects: '**\*.csproj'
publishWebProjects: false
zipAfterPublish: true
arguments: '--output $(Build.ArtifactStagingDirectory)/$(buildConfiguration)'
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
You could use '**/*.csproj' but honestly, I would do something like this answer and add a script to list out all the files and folders recursively before this step that fails.
Assuming that you have a restore or build step before this publish you could add it after those, or just as the first step after your checkout one.
You can also inspect the logs of earlier steps to see the file path/s., instructions on doing this are available here.
Using $(System.DefaultWorkingDirectory) as your root is also recommended, rather than .\, so you would have '$(System.DefaultWorkingDirectory)\af-process-mds-vehicle-output-to-deviation...'.
Edit
If you look at the logs for your build step you will see entries like /home/vsts/work/1/s/XXX.YYY.ZZZ/XXX.YYY.ZZZ.csproj that refer to the different projects inside your solution. By default most commands will be run in $(System.DefaultWorkingDirectory) which would equate to /home/vsts/work/1/s/ in this instance, you can think of it as the root of your repository - there is more information on this structure here.
The error you were encountering is actually about the lack of a web project, rather than a path issue though, for the build step it is best practice to use the --output <output-directory-here> flag to output the compile files into a specific folder, that way you can easily publish that folder.

Not Loading Indexed Sources for nuget packages from Azure Devpos during debugging

Trying to use azure yml for build pipleline to publish symbols to allow nuget pkg to be debuggable usin azure devops. I see PDB files are donwloaded to the symbols cache folder but stepping thru is asking for source file location in visual studio, even when i have indexed the source code during publish symbol.
I have tried to enable different options in visual studio debugging but nothing seems to help
Here is my yml
# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/dotnet-core
name: $(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r) # need this for byBuildNumber verisonScheme nuget pack
# the build will trigger on any changes to the master branch
trigger:
- master
# the build will run on a Microsoft hosted agent, using the lastest Windows VM Image
pool:
vmImage: 'windows-latest'
# these variables are available throughout the build file
# just the build configuration is defined, in this case we are building Release packages
variables:
buildConfiguration: 'Release'
#The build has 3 seperate tasks run under 1 step
steps:
# The first task is the dotnet command build, pointing to our csproj file
- task: DotNetCoreCLI#2
displayName: 'dotnet build'
inputs:
command: 'build'
arguments: '--configuration $(buildConfiguration)'
projects: 'src/Common.Core/Common.Core.csproj'
- task: PublishSymbols#2
inputs:
symbolsFolder: '$(Build.SourcesDirectory)'
searchPattern: '**/bin/**/*.pdb'
indexSources: true
publishSymbols: true
symbolServerType: 'teamServices'
treatNotIndexedAsWarning: true
symbolsProduct: '$(Build.DefinitionName)'
symbolsVersion: '$(Build.BuildNumber)'
symbolsArtifactName: '$(name).Symbols_$(BuildConfiguration)'
# The second task is dotnet pack command again pointing to the csproj file
# The nobuild means the project will not be compiled before running pack, because its already built in above step
- task: DotNetCoreCLI#2
displayName: "dotnet pack"
inputs:
command: 'pack'
arguments: '--configuration $(buildConfiguration)'
packagesToPack: 'src/Common.Core/Common.Core.csproj'
nobuild: true
includeSymbols: true
versioningScheme: 'byBuildNumber'
# The last task is a nuget command, nuget push
# This will push any .nupkg files to the 'Nuget' artifact feed
# allowPackageConflicts allows us to build the same version and not throw an error when trying to push
# instead it just ingores the latest package unless the version changes
- task: NuGetCommand#2
displayName: 'nuget push'
inputs:
command: 'push'
feedsToUse: 'select'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: 'myNuget'
allowPackageConflicts: true
I would expect that when i am debugging nuget packages with symbols enabled with idnexed soruce code, it automatically downloads the pdf file and the source code.
Visual Studio Settings for debugger
I see PDB files are donwloaded to the symbols cache folder but
stepping thru is asking for source file location in visual studio,
even when i have indexed the source code during publish symbol.
You should let the debugger know where to find your source files. First, please rename your xx.nupkg to xx.zip and check if it contains necessary source files.
After that you can right-click Solution in Solution Explorer=>Properties=>Debug Source Files,click the New Line option to add the path of your nuget source files to the debug source files setting.
I would expect that when i am debugging nuget packages with symbols
enabled with idnexed soruce code, it automatically downloads the pdf
file and the source code.
Maybe you can get some help from this issue. You can try setting the build action of the source files as C# compiler when you create the nuget package for .net core.

VSTS build is not generating .msi file using .vdproj

I have VSTS Build which will generate the .msi file using .vdproj but I am not getting the .msi file out of the build.
I am getting the Warning MSB4078: The project file "abcdSetup\abcdSetup.vdproj" is not supported by MSBuild and cannot be built.
I am using Visual studio build task and MS build task to generate the .msi.
I have tried some ways and I installed third part task called create .msi file from VS installer Project.
I have attached the Snapshot of all the tasks using to generate this .msifile.
Please have a look and help me on this and also do let us know is there any task available in VSTS to create .msi file.
It wasn't possible until agent image Windows2019 was published. The new image is equipped with an extension for vdproj that is called Microsoft Visual Studio Installer Projects.
Steps:
Add a Command line task
Add there following line: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.com" MyProjectDir\MySolution.sln /Rebuild Release
Remark: please note to use devenv.com (not devenv.exe). The "com" version outputs build log and errors to the console (standard output).
In 2022 today, looks like the Azure DevOps includes the Microsoft Visual Studio Installer Projects extension.
I was able to get a build using below pipeline configuration:
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
BuildConfiguration: 'Release'
BuildPlatform: 'Any CPU'
InstallerProject: 'YourInstallerProject/YourInstallerProject.vdproj'
Solution: 'YourSolution.sln'
VisualStudioPath: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise'
steps:
- task: NuGetToolInstaller#1
displayName: 'Install Nuget CLI'
- task: NuGetCommand#2
displayName: 'Restore packages'
inputs:
restoreSolution: '$(Solution)'
- task: CmdLine#2
displayName: 'Prepare for MSI build'
inputs:
script: 'DisableOutOfProcBuild.exe'
workingDirectory: '$(VisualStudioPath)\Common7\IDE\CommonExtensions\Microsoft\VSI\DisableOutOfProcBuild'
- task: VSBuild#1
displayName: 'Build primary project'
inputs:
solution: '$(Solution)'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
- task: CmdLine#2
displayName: 'Build installer project'
inputs:
script: '"$(VisualStudioPath)\Common7\IDE\devenv.com" "$(Solution)" /Project "$(InstallerProject)" /Build "$(BuildConfiguration)|$(BuildPlatform)"'
- task: CopyFiles#2
displayName: 'Copy MSI files'
inputs:
sourceFolder: '$(Build.SourcesDirectory)'
contents: '**/$(BuildConfiguration)/**/?(*.msi)'
targetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts#1
displayName: 'Publish artifacts'
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: drop
Make sure to update the values of Solution and InstallerProject variables. If you would like to build with a Visual Studio version other than 2022, you must also edit VisualStudioPath variable.
I am getting the Warning MSB4078: The project file "abcdSetup\abcdSetup.vdproj" is not supported by MSBuild and cannot be built
That because MSBuild/Visual Studio does not have support for setup projects. To integrate with Azure DevOps, you will have to use devenv.
Note: starting VS 2013, .vdproj support is provided by an add-in.
That the reason why you got the error Warning MSB4078: The project file "abcdSetup\abcdSetup.vdproj" is not supported by MSBuild and cannot be built
Is there any way that we can generate .msi without setting up the
Private agent in VSTS ? Please let me know is there any task available.
I am afraid there is no such way you can generate .msi without setting up the Private agent in Azure DevOps, otherwise, we will always get the error:
Some errors occurred during migration. For more information, see the migration report: C:\VSTS-vs2017-agent\_work\9\s\Setup1\UpgradeLog.htm
I test it on the Private agent and local PC without installing the Visual Studio Installer Projects extension and got the same result. Then I installed that extension on the local PC and it works fine. So, we have to install the Visual Studio Installer Projects extension, if we want to build the setup projects.
Hope this helps.

Azure Pipelines build fails with Error MSB3774: Could not find SDK "Microsoft.Services.Store.Engagement, Version=10.0"

Sorry for my bad English.
UWP solution created with Windows Template Studio, targeting 17763 SDK. I have selected FeedbackHub resource, which installs and references Microsoft.Services.Store.Engagement NuGet package. On my local machine the solution builds and runs as expected, but when Azure Pipelines runs the build fails in VSBuild with Error MSB3774, stating that Microsoft Store Services SDK isn't installed.
I adapted the PowerShell script on this question to download and install the SDK, but the build still fails.
How can I tell Azure Pipelines to install Microsoft Store Services SDK before VSBuild?
My azure-pipelines.yml:
# Universal Windows Platform
# Build a Universal Windows Platform project using Visual Studio.
# Add steps that test and distribute an app, save build artifacts, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
vmImage: 'VS2017-Win2016'
variables:
solution: '**/*.sln'
buildPlatform: 'x86|x64|ARM'
buildConfiguration: 'Release'
appxPackageDir: '$(build.artifactStagingDirectory)\AppxPackages\'
steps:
- task: NuGetToolInstaller#0
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild#1
inputs:
platform: 'x86'
solution: '$(solution)'
configuration: '$(buildConfiguration)'
msbuildArgs: '/p:AppxBundlePlatforms="$(buildPlatform)" /p:AppxPackageDir="$(appxPackageDir)" /p:AppxBundle=Always /p:UapAppxPackageBuildMode=StoreUpload'
I thank for any help I can have.

##[error]Project file(s) matching the specified pattern were not found

I am having problems with a build pipeline.
The agent pools is hosted VS2017
The YAML is
pool:
vmImage: 'VS2017-Win2016'
variables:
buildConfiguration: 'Debug'
steps:
- task: DotNetCoreInstaller#0
displayName: 'Use .NET Core sdk 2.1.5'
inputs:
version: 2.1.403
- task: DotNetCoreCLI#2
displayName: Restore
inputs:
command: restore
projects: '**/Api*.csproj'
#Your build pipeline references an undefined variable named ‘Parameters.projects’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references the ‘BuildConfiguration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
- task: DotNetCoreCLI#2
displayName: Build
inputs:
projects: '$(Parameters.projects)'
arguments: '--configuration $(BuildConfiguration)'
#Your build pipeline references an undefined variable named ‘Parameters.projects’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references the ‘BuildConfiguration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
- task: DotNetCoreCLI#2
displayName: Publish
inputs:
command: publish
publishWebProjects: false
projects: '$(Parameters.projects)'
arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
When it runs, the build task has the following log
2018-10-29T18:28:43.7087338Z ##[section]Starting: Build
2018-10-29T18:28:43.7093502Z ==============================================================================
2018-10-29T18:28:43.7093580Z Task : .NET Core
2018-10-29T18:28:43.7093785Z Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command. For package commands, supports NuGet.org and authenticated feeds like Package Management and MyGet.
2018-10-29T18:28:43.7093818Z Version : 2.141.0
2018-10-29T18:28:43.7093864Z Author : Microsoft Corporation
2018-10-29T18:28:43.7093895Z Help : [More Information](https://go.microsoft.com/fwlink/?linkid=832194)
2018-10-29T18:28:43.7093925Z ==============================================================================
2018-10-29T18:28:44.4833128Z [command]C:\Windows\system32\chcp.com 65001
2018-10-29T18:28:44.4926077Z Active code page: 65001
2018-10-29T18:28:45.1965225Z ##[error]Project file(s) matching the specified pattern were not found.
2018-10-29T18:28:45.2037015Z ##[section]Finishing: Build
I note that the log refers to 2.141.0 where as I am restoring the latest SDK 2.1.403 Why would that be? Could it be that the hosted VS2017 agent does not support the latest version of .netcore?
[Update]
I added a variable for Parameters.projects
However the build task has an error still.
2018-10-29T21:07:38.6774331Z ##[section]Starting: Build
2018-10-29T21:07:38.6781540Z ==============================================================================
2018-10-29T21:07:38.6781632Z Task : .NET Core
2018-10-29T21:07:38.6781676Z Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command. For package commands, supports NuGet.org and authenticated feeds like Package Management and MyGet.
2018-10-29T21:07:38.6781762Z Version : 2.141.0
2018-10-29T21:07:38.6781807Z Author : Microsoft Corporation
2018-10-29T21:07:38.6781853Z Help : [More Information](https://go.microsoft.com/fwlink/?linkid=832194)
2018-10-29T21:07:38.6781915Z ==============================================================================
2018-10-29T21:07:39.5030735Z [command]C:\Windows\system32\chcp.com 65001
2018-10-29T21:07:39.5157531Z Active code page: 65001
2018-10-29T21:07:39.5840366Z ##[error]Project file(s) matching the specified pattern were not found.
2018-10-29T21:07:39.5916864Z ##[section]Finishing: Build
Posting just in case this helps anyone in the future
I had my vmImage set as ubuntu with the following set:
projects: '**\*.csproj'
The backslash was throwing things off, I had to switch to the following:
projects: '**/*.csproj'
I copied from a guide that was assuming Windows. Subtle enough, it took me a while to notice 😅
You need to define in the build task which .csproj files you want to build.
In your case, the definition is in a variable $(Parameters.projects).
- task: DotNetCoreCLI#2
displayName: Build
inputs:
projects: '$(Parameters.projects)'
arguments: '--configuration $(BuildConfiguration)'
You can replace this variable in your .csproj (e.g. **/*.csproj for all .csproj files in all subfolders):
- task: DotNetCoreCLI#2
displayName: Build
inputs:
projects: '**/*.csproj'
arguments: '--configuration $(BuildConfiguration)'
Or go to the variables tab and add the Parameters.projects variable:
I am trying to build and publish a multiproject solution in dotnet core.
The solution structure is:
sampleTest.API
sampleTest.API.csproj
sampleTest.Data
sampleTest.Data.csproj
sampleTest.Identity
sampleTest.Identity.csproj
sampleTest.Web
sampleTest.Web.csproj
sampleTest.sln
Now, I just want to build the sampleTest.API dotnet core project. I just need to define in the build task, the path to the project as shown below.
The yaml file for build task for the pipeline in Azure Deveops is shown below:
steps:
- task: DotNetCoreCLI#2
displayName: Build
inputs:
projects: 'sampleTest.API/*.csproj'
arguments: '--configuration $(BuildConfiguration)'
If we need to build based on searching for all the 'cs.proj' files - we do
projects: '**/*.csproj'
Sample build task using the classic Editor in Azure Devops is shown below: