Azure DevOps Builds the Solution Differently Than Visual Studio Locally - azure-devops

We are having a problem with Azure DevOps Build Pipelines producing different files than Visual Studio locally. Our Visual Studio 2019 solution has 24 C# based projects.
Some crucial DLLs (sites don’t work without them) that are being put into Bin folder when building the solution locally in Visual Studio are missing in when building the solution via Azure DevOps Build Pipelines. The missing DLLs do exist in packages.config.
Here is a screenshot of WinMerge showing that some files exist in Azure DevOps Build Pipelines and missing in Visual Studio locally and vice versa.
[
Azure DevOps YAML build task:
- task: VSBuild#1
inputs:
solution: 'Solution.sln'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
msbuildArgs: '/p:OutputPath="$(build.binariesDirectory)\Output\bin"'
How do we debug such behavior and make our builds exactly the same locally and in Azure DevOps?

I tested with default msbuildArgs in my .Net Core Web Application, and everything works fine.
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'

I don't know why, but running MSBuild without any arguments fixed the problem. If somebody could shine some light on that behavior, that would be great!

Related

VSBuild task not able to find vsVersion ='14.0'

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.

Azure Devops Build Pipeline - files are not published

I'm trying to publish my application using a VS publish profile. When I publish through Visual Studio it works successfully, but through DevOps the publish does not work. The build is successful in both. Here is my VSBuild task definition:
inputs:
solution: '$(solution)'
msbuildArgs: '/t:Restore /p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:PublishBaseUrl=$(build.artifactstagingdirectory)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
Try to use /p:publishUrl instead of /p:PublishBaseUrl. If it still doesn't work, share your pubxml file and DevOps build log.
You are using publish profile, so you could specify the MSBuild argument like this: /p:DeployOnBuild=true /p:PublishProfile=myprofile
Related thread: Using msbuild to execute a File System Publish Profile

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!

Azure Devops deploying Azure C# Function

I'm failing to use the Azure Devops Release management to deploy my Azure Functions.
Build
In the build pipeline, I've got two tasks:
dotnet publish
publich release artifact
This step succeeds
The artifact is published into /drop/a.zip
Release
In this step I have a Dev environment.
and a single task:
Azure Function App Deploy.
Credentials and which app to deploy to is specified.
There is a path specified to the release artifact like so:
I can even browse the path with the browse button in that image. and navigate to and pick the correct zip there.
But once this task runs. it all ends with a
##[error]Error: No package found with specified pattern: D:\a\r1\a\DotnetFunctions-CI\drop\a.zip
I am aware there are other questions here on SO bringing up the same question. however the answers I've seen there does not solve the issue here.
What am I missing?
I've had issue with the release pipeline not finding an artifact. What I've started doing is using the double wildcard search instead of the full path.
That is in my Deploy Azure App Service task inside the release pipeline.
My azure function works:
In Build :
Visual Studio Build Task :
Add following arguments in MSBuild section :
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\$(BuildConfiguration)\\"
here is my build and release:
Build Configuration:
Release :