VSBuild task not able to find vsVersion ='14.0' - azure-devops

In one of my pipeline, I am trying to build a solution which is created using VS2015. I am using a on-prem agent.
I am using VSBuild task as shown below
- task: VSBuild#1
inputs:
solution: '**\*.sln'
vsVersion: '14.0'
configuration: 'release'
clean: true
When I run this pipeline, in the logs I can see this warning
##[warning]Visual Studio version '14.0' not found. Falling back to version '16.0'.
Do I have to install something more in the agent? Agent capability is showing me multiple MSBuild versions

Visual Studio version 14.0 referes to Visual Stuido 2015 which is not installed on you agents based on this screenshot. So if you want to use this, you need install if on your agent.

Related

How do I run NUnit tests in Azure Devops without having the test adapter in every project?

My team has many test projects containing NUnit tests (version 3). We do not use the Visual Studio test runner and we do not have the test adapter (NUnit3TestAdapter) referenced in any of our projects. How can we run our tests in an Azure Devops build pipeline without going through all projects to add the test adapter reference?
We solved the problem by adding the following task to our pipeline, before the VSTest task:
- task: CmdLine#2
inputs:
script: 'nuget install NUnit3TestAdapter'
You can add nuget package to yor projects, but you don't have to go project by project. You can add it in single step.
Please take a look here:
NuGet for solutions with multiple projects

Installing the Visual Studio 2015 toolkit (v140) on a Microsoft hosted Azure Devops Build Pipeline Agent

I have a legacy solution that we've moved into an Azure Devops git repo and I am trying to setup a build pipeline for it. The solution is a mixture of v141 (2017) and v140 (2015) projects, which on my local machine I can just build in Visual Studio 2017 as long as I've installed the v140 toolset.
Ideally, I'd like to use a Microsoft provided agent but it seems like the vs2017-win2016 image does not include the v140 toolset by default. As this is not something we are planning to build very often, I attempted to install the v140 toolset using the 2017 installer:
pool:
vmImage: 'vs2017-win2016'
steps:
- task: PowerShell#2
displayName: 'Install Visual Studio v140 Toolset'
inputs:
targetType: 'inline'
script: |
Write-Output "Starting the installation process. This will take some time"
$installProcess = Start-Process -FilePath $(Build.SourcesDirectory)/External/VisualStudioBuildTools/installer.exe -ArgumentList "--add Microsoft.VisualStudio.Component.VC.140", "--quiet", "--wait", "--norestart" -Wait -PassThru
Write-Output "Install Completed with code $($process.ExitCode)"
- task: VSBuild#1
displayName: 'Build Debug [.sln]'
inputs:
solution: '$(Build.SourcesDirectory)/LegacySolution.sln'
vsVersion: '15.0'
configuration: 'Debug'
platform: 'x64'
When I run this in Azure Devops, the install process exits with code 0 (success) after about a minute. However, when it then tries to build the solution it fails with:
##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Platform.targets(67,5): Error MSB8020: The build tools for v140 (Platform Toolset = 'v140') cannot be found. To build using the v140 build tools, please install v140 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution".
Has anyone tried this before with any luck? The only other thing I can think of is to try to check in a copy of the v140 toolset and play with adding it correctly to the path, but I can see this being a major pain to get right!
Installing the Visual Studio 2015 toolkit (v140) on a Microsoft hosted Azure Devops Build Pipeline Agent
In generally you can't. If something requires admin access and you're using the hosted agent, you can't do that thing. I have test this command line in my local, I need to run the powershell with Administrator, otherwise, I will get a confirmation prompt.
Besides, MS replied:
VS has grown to a point, where installing multiple versions on the
same agent is not feasible any longer for us. Also, we notice problems
in side-by-side VS installations for certain project types. For these
reasons, we have decided to keep a single tool set going forward. If
you need multiple versions, then you would have to setup custom
agents. We are sorry that we cannot meet all of our customers'
requirements using a common hosted agent image.
So, to resolve this issue, we have to setup our private agent.
Hope this helps.

SpecFlow Example with azure-pipelines.yml for Azure DevOps

I am trying to get a simple SpecFlow+ example up and running on Azure DevOps.
Currently I get the following Error Message:
SpecFlow+LivingDoc: An error happened during the execution: The SDK
'Microsoft.NET.Sdk' specified could not be found.
How do I install the required "Microsoft .NET Test SDK 15"?
Can somebody point me to a simple example SpecFlow setup for Azure DevOps?
All details can be found on this public Azure DevOps project:
https://dev.azure.com/FlorianBoehmak/_git/SpecFlowCalculator
EDIT
Thanks #Levi Lu-MSFT for pointing me into the right direction. I put everything together into a github repository (including a devops generator). Enjoy :-)
https://github.com/fnbk/SpecFlowCalculator
In the yaml pipeline definition, it seems that the vstest task didnot specify the test .dll file. You can try specifying the test dlls like below.
- task: VSTest#2
inputs:
testAssemblyVer2: |
**\Calculator.Spec.dll
!**\obj\**
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
And if your project is a .net core project, the Project file path field in the SpecFlow+
is the path containing your project, not the project itself. You can try setting the projectfilepath to you root directory of your source repo like below.check here
- task: SpecFlowPlus#0
inputs:
projectFilePath: '$(System.DefaultWorkingDirectory)'
projectLanguage: 'en'
Hope above can be of some help!

'Allow duplicates to be skipped' warning and 409 error for NuGet push on Azure DevOps Server

In Azure DevOps Server (version 2019.0.1) running on a Windows Server 2019 agent, with the 'Allow duplicates to be skipped' option selected for NuGet push task, a warning is displayed:
The 'Allow duplicates to be skipped' option is currently only available on Azure Pipelines. If NuGet.exe encounters a conflict, the task will fail.
The task results in the following error that causes the task to fail indicating that the above warning applies:
Response status code does not indicate success: 409 (Conflict - The feed already contains 'MyPackage X.Y.Z'. (DevOps Activity ID: 1A57312F-3C56-4E4D-9E78-73C7072A288F)).
I'm wondering if this issue is particular to Azure DevOps Server (rather than Azure DevOps Services), or if I'm doing something wrong, or if there is another workaround. I noticed someone else has the same issue from this comment on another question where it was mentioned that the option was available after someone asked how to ignore error 409 (duplicate package).
I would like to ignore duplicate packages using the NuGet task and ideally the 'Allow duplicates to be skipped' option on Azure DevOps Server. I'm aware that it could be resolved using scripting, but I'd prefer to avoid that if possible. Any help appreciated.
I don't know about the Azure DevOps task, but if you upgrade to nuget.exe 5.1, you can use the new -SkipDuplicate option. This should work for any NuGet server that correctly implements the NuGet protocol and on any CI server/agent.
If you're using the NuGetCommand#2 Azure Pipelines task, you can use the allowPackageConflicts parameter.
allowPackageConflicts
It allows the task to report success even if some of your packages are rejected with 409 Conflict errors.
This option is currently only available on Azure Pipelines and using Windows agents. If NuGet.exe encounters a conflict, the task will fail. This option will not work and publish will fail if you are within a proxy environment.
— https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/package/nuget
If you switch to azure pipelines (it seems it's the new way of doing things) you can use dotnet commands.
the option --skip-duplicate will be available in dotnet core 3.1 (still in preview) for the dotnet nuget push command (no need to use NuGet command as it's already available in dotnet).
But you can use it now if you install the latest .NET Core.
For example, this is a stage that will grab whichever nuGet you've got in a specific folder, install the latest dotnet core that supports the skip duplicates and push it to the repository feed.
- stage:
displayName: 'Release'
condition: succeeded()
jobs:
- job: 'Publish'
displayName: 'Publish nuGet Package'
steps:
- download: current
artifact: $(PIPELINE_ARTIFACT_NAME)
displayName: 'Download pipeline artifact'
- script: ls $(PATH_PIPELINE_ARTIFACT_NAME)
displayName: 'Display contents of downloaded articacts path'
- task: NuGetAuthenticate#0
displayName: 'Authenticate in NuGet feed'
- task: UseDotNet#2
displayName: 'Use .NET Core sdk 3.1 (preview)'
inputs:
packageType: sdk
version: '3.1.100-preview2-014569'
installationPath: $(Agent.ToolsDirectory)/dotnet
- script: dotnet nuget push $(PATH_PIPELINE_ARTIFACT_NAME)/**/*.nupkg --source $(NUGET_FEED) --api-key $(NUGET_API_KEY) --skip-duplicate
displayName: 'Uploads nuGet packages'

How to automate Visual Studio Code extensions packaging in Azure DevOps?

I have successfully setup Azure DevOps to automatically build my Visual Studio Code extension from a git repo, but I cannot find a way to generate the .vsix file. That is, I can create it locally, but I want to generate it for every build automatically, so I can download it once the build has finished.
Thanks!
I use this extension to generate Visual Studio extension's VSIX:
https://marketplace.visualstudio.com/items?itemName=ms-devlabs.vsts-developer-tools-build-tasks&targetId=18354d24-b805-4494-a4b9-c57440acfeea
This extension is free, and it's from Microsoft DevLabs.
It is also open source at this GitHub repo: https://github.com/Microsoft/vsts-extension-build-release-tasks
NOTE: According to my own experience using this extension, it is not compatible with some releases of Visual Studio before Visual Studio 2015 Update 1. It is compatible with Visual Studio 2015 Update 1/Update 2/Update 3, and Visual Studio 2017 release 15.3.0 or later.
In the end, I have found my own answer, by installing vsce, and calling it for packaging the .vsix
- task: Npm#1
displayName: 'Install vsce'
inputs:
command: custom
verbose: false
customCommand: 'install -g vsce'
- script: 'vsce package'
displayName: 'Package .vsix'