I have a build pipeline yaml file that looks like the following:
# ...
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Production 12'
# ...
- task: VSBuild#1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
The Production 12|Any CPU configuration is supposed to be built.
But it is not, another one is (Test|Any CPU), as shown in the logs:
Starting: VSBuild
==============================================================================
Task : Visual Studio build
Description : Build with MSBuild and set the Visual Studio version property
Version : 1.199.0
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/visual-studio-build
==============================================================================
"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.199.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [17.0,18.0) -latest -format json
"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.199.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [17.0,18.0) -products Microsoft.VisualStudio.Product.BuildTools -latest -format json
"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.199.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [16.0,17.0) -latest -format json
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" "D:\a\1\s\SafeProtect.sln" /nologo /nr:false /dl:CentralLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.199.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=10c69004-b8fb-410e-ba0d-6d600dac481c|SolutionDir=D:\a\1\s|enableOrphanedProjectsLogs=true"*ForwardingLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.199.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="D:\a\1\a\WebApp.zip" /p:platform="Any CPU" /p:configuration="Test" /p:VisualStudioVersion="16.0" /p:_MSDeployUserAgent="VSTS_09716650-7645-4cc6-8318-3b574bba08b5_build_1_0"
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 3/17/2022 12:36:04 PM.
Project "D:\a\1\s\SafeProtect.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Test|Any CPU".
What is happening ?
Azure Devops build pipelines : build configuration in Yaml file not used
First, try to check if you missing build configuration in the Configuration Properties with Visual Studio or the checkbox of build is not checked.
Right clicking the solution, selecting "Properties" and then looking at the "Configuration Properties" property sheet:
Second, try to build and deploy it on your local to check if you have this issue, if not, please check the MSBuild version (Visual Studio Version) and the .net framework version with the version on the Azure devops.
I solved the problem by recreating the build pipeline (.yml file).
So I guess that there is a glitch while processing the .yml file when it is modified to update the pipeline tasks.
Related
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.
I have problems to get my gtest runing in my build pipeline. My solution works well to build and run test case in Visual Studio 2017. On the DevOps environment I use .Net Desktop setup with minor modification. The build task work fine as well in pipeline.
I try use default VSTest task, but I'm not sure it right task for run Google Test that is create with Visual Studio project from VS IDE.
Build pipline yml script
# .NET Desktop
trigger:
- master
# Install build environment
pool:
vmImage: 'windows-latest'
name: Hosted VS2017
variables:
solution: '**/*.sln'
buildPlatform: 'x86'
buildConfiguration: 'Debug'
steps:
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
# Build VS solutions including gtest project.
- task: VSBuild#1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
# Run gTest, this task not working see log below.
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
VSTest log output
Running tests using vstest.console.exe runner.
======================================================
Test selector : Test assemblies
Test filter criteria : null
Search folder : d:\a\1\s
VisualStudio version selected for test execution : latest
Attempting to find vstest.console from a visual studio installation with version [16.0,17.0).
Attempting to find vstest.console from a visual studio build tools installation with version [16.0,17.0).
Attempting to find vstest.console from a visual studio installation with version [15.0,16.0).
Run in parallel : false
Run in isolation : false
Path to custom adapters : null
Other console options : null
Code coverage enabled : false
Diagnostics enabled : false
SystemVssConnection exists true
Run the tests locally using vstest.console.exe
========================================================
##[warning]No test assemblies found matching the pattern: **\*test*.dll,!**\*TestAdapter.dll,!**\obj\**.
Yes, VSTest task which will use VSTest.Console.exe. It's able to run custom test adapters (like the Google Test Adapter).
However, after go through the build-in Included Software of Hosted VS2017 build agent, it's not listed. If so, you could use Self-hosted Windows agents.
You can download the Google Test Adapter as Visual Studio Extension, unzip it (rename .vsix file to .zip) and place that entire unzipped folder somewhere on your Build agent machine. The build step then has to point to that directory.
Additionally of course, your project should include the "googletest" NuGet package in order to run the tests.
If you still not able to get it work, please remote to build agent machine and manually run the build and test use visual studio or command line instead through Azure DevOps pipeline. This will narrow down if it's an environment issue.
I am trying to build a repository in Azure Pipelines. It builds OK in Visual Studio, but when using Azure Pipelines (with an agent running on a build machine), it fails with the following error:
The nuget command failed with exit code(1) and error
Project MyProject is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2).
Project MyProject supports: netstandard2.0 (.NETStandard,Version=v2.0)
How can I fix this?
And here is the yaml build script:
pool:
name: MyBuildServer
demands:
- msbuild
- visualstudio
steps:
- task: NuGetCommand#2
displayName: 'NuGet restore'
- task: VSBuild#1
displayName: 'Build solution **\*.sln'
- task: VSTest#2
displayName: 'Run tests'
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\*test*.dll
!**\*TestAdapter.dll
!**\obj\**
searchFolder: '$(System.DefaultWorkingDirectory)'
NuGet Restore task fails (not compatible with netcoreapp2.2), but it works in Visual Studio
It seems that the version of nuget used on the Azure pipeline is not the latest version, which may cause the incompatibility issues.
To resolve this issue, you can try to add a NuGet Tool Installer task point it to a Version of NuGet.exe to install, which you simply specify the version number of the desired NuGet.exe you want to execute in the build.
Once this have been properly configured, the builds all succeeded using the latest incarnation of .net core.
Besides, if above not resolve your question, you can try to use the dotnet restore task instead of nuget restore task.
Hope this helps.
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.
Trying to create a build configuration in Azure DevOps, using the new YAML build feature, however I can't seem to get NuGet restore to work when referring to a NuGet.config file (places in the root of my projectfolder)
In my YAML build file I have:
- task: NuGetCommand#2
displayName: 'NuGet restore'
inputs:
restoreSolution: '$(Parameters.solution)'
feedsToUse: config
nugetConfigPath: 'NuGet.config'
In my log I get the following:
2018-09-25T17:25:07.4624712Z ##[section]Starting: NuGet restore
2018-09-25T17:25:07.4631787Z ==============================================================================
2018-09-25T17:25:07.4631904Z Task : NuGet
2018-09-25T17:25:07.4632707Z Description : Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds like Package Management and MyGet. Uses NuGet.exe and works with .NET Framework apps. For .NET Core and .NET Standard apps, use the .NET Core task.
2018-09-25T17:25:07.4632875Z Version : 2.0.41
2018-09-25T17:25:07.4632964Z Author : Microsoft Corporation
2018-09-25T17:25:07.4633086Z Help : [More Information] (https://go.microsoft.com/fwlink/?LinkID=613747)
2018-09-25T17:25:07.4633196Z ==============================================================================
2018-09-25T17:25:08.2066658Z SYSTEMVSSCONNECTION exists true
2018-09-25T17:25:08.2581545Z SYSTEMVSSCONNECTION exists true
2018-09-25T17:25:08.3645811Z [command]C:\Windows\system32\chcp.com 65001
2018-09-25T17:25:08.3743733Z Active code page: 65001
2018-09-25T17:25:08.4044581Z Detected NuGet version 4.7.0.5148 / 4.7.0+9245481f357ae542f92e6bc5e504fc898cfe5fc0
2018-09-25T17:25:08.4061452Z SYSTEMVSSCONNECTION exists true
2018-09-25T17:25:08.4082708Z Saving NuGet.config to a temporary config file.
2018-09-25T17:25:08.4321725Z ##[section]Finishing: NuGet restore
I've tried using
nugetConfigPath: '$(Build.SourcesDirectory)\\NuGet.config'
instead, with the same result
Any ideas on how to get NuGet restore to work with a NuGet.config file?
I've figured it out, the NuGet task needs to be changed to:
- task: NuGetCommand#2
displayName: 'NuGet restore'
inputs:
restoreSolution: '**\*.sln'
feedsToUse: config
nugetConfigPath: 'NuGet.config'
(The only thing which needed changing is restoreSolution.)
I also ran into this. I added the nuget.config to the solution(like any other class or interface) and it needed to be added where the .sln file was located.
e.g. If you didn't click the "Place solution and project in same directory" check box on project creation. Move the nuget.config one level up in your project.