Build failing while creating Azure Build pipeline - Error MSB3073 - VSBuild Task - azure-devops

We were trying to build a pipeline using MS Hosted agent with vmImage (vs2017-win2016) for a .net application, but build id is failing with following errors..Any ideas? Now, same source code successfully builds on On-premise build server & since we are now using Azure Devops to create build pipeline using MS Hosted agent, its failing.
This is the only build error we are getting right now. Any valuable comments or inputs highly appreciated.
Error details are as below:
Error analysis
Build solution (VSBuild) - VSBuild Task
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(5165,5): Error MSB3073: The command "copy "D:\a\1\s\Modules\HP.AMI.Modules.VirtualHeadEnd\ResponseTemplates*.xml" C:\AMI\Templates " exited with code 1.

Build failing while creating Azure Build pipeline - Error MSB3073 - VSBuild Task
When you got the MSBuild error MSB3073, that means the path of the custom command line or custom target in your project is not correct. You need to check the path of that command line.
According the comment you replied, you have post-build event command line:
copy "$(ProjectDir)ResponseTemplates*.xml" C:\AMI\Templates
When you execute this command line without existing folder C:\AMI\Templates, the copy command will report an error of Error MSB3073. Because the target folder cannot be found.
To resolve this issue, we just need to add another post-build event command line to create the folder before the copy command line, like:
md C:\AMI\Templates
copy "$(ProjectDir)TextTemplate1.txt" "C:\AMI\Templates"
Now, we could build it with hosted agent vmImage (vs2017-win2016):

Related

nuget pack task in Azure Dev ops pipeline gives error

Hi i'm a newbie to azure devops CID and pipelining.
the azure devops is on premise, my pipeline looks as below however it fails at nuget pack command (2nd from bottom)
the error i get is ##[error]The nuget command failed with exit code(1) and error(Error NU5012: Unable to find 'C:\AzureDevOpsAgents\Agent#1_work\4\s\Code\MyCompany.Core\bin\release\net472\MyCompany.Core.dll'. Make sure the project has been built.
I went into the azure agents directory and the dll is located C:\AzureDevOpsAgents\Agent#1_work\4\s\Code\MyCompany.Core\bin\x64\Release\net472\MyCompany.Core.dll
the difference being the x64, so how i can i get nuget pack to take into consideration the architecture as part of the pack path
variables
ok i as usual every time i post a question on here, despite struggling for hours i manage to solve it.
I've added $(BuildPlatform)\ in front of the default $(BuildConfiguration) for the configuration to package and i can see a package in the location

The SonarQube code analysis task in our Azure Devops build pipeline yaml getting failed with storage issue in default location

Issue:- The SonarQube code analysis task in our Azure Devops build pipeline yaml getting failed with below error.
What we tried: We have SonarQube analysis task yaml in our AzureDevops pipeline and there is a maven task which using "clean verify" goal followed by the sonarqube task. when we execute this the maven task getyting failed with the below error.
Failed to execute goal
org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar on
project: Unable to load component interface
org.sonar.api.utils.TempFolder: Failed to create temporary folder in
/home/vowne/.sonar: /home/vowne/.sonar/.sonartmp_xxxxxxx: No space
left on device.
Not sure from where the sonarqube is taking the location from . its taking the users home directory now. /home/vowne. We have enough space in other location and would need to change the sonarqube temp location to there.
Is there something we can add to the maven task or sonar task to change the location of this temp ?
- task: SonarQubePrepare#4
inputs:
SonarQube: 'Sonarqube'
ScannerMode: 'Other'
extraProperties: |
sonar.projectName=${{ parameters.myName }}
sonar.coverage.xxxxxx.xmlReportPaths=$(System.DefaultWorkingDirectory)/xxxxxxx/xxxxxx/site/xxxxx/xxxxx.xml
Here can we add an extra property to the sonar task like sonar.userHome=$(System.DefaultWorkingDirectory)
or maven task need to change ""goal" from "clean verify" to some customised values.
According to source code this path is derived from the following properties:
sonar.globalWorking.directory system property (resolved relative to settings below if not absolute),
sonar.userHome system property,
SONAR_USER_HOME environment variable,
.sonar directory under user.home system property.
It seems that the last case matches your scenario. Try to set one of the above settings to select different location instead of ~/.sonar.

How to build Visual Studio Installer Project in Azure Pipelines in Self-Hosted Windows Agent

The image above shows my Hello World project structure. I am trying to build the Setup-HelloWorld-x86.vdproj in Azure Pipeline in Self-Hosted Windows Agent (which is nothing but my local machine) by using the command line script task like shown in below image.
But I get the following error.
Kindly help me to build this Setup-HelloWorld-x86.vdproj
If you want to run the project via cmd devenv, you can refer to this doc.
As a workaround, you can install the extension Build VS Installer and use the task DutchWorkz - Build VS Installer(s) to build Visual Studio Installer Project in Azure Pipelines.
You can specify to build .sln or .vdproj to generate .msi file(s) in Task-mode option.
Update1
Thanks Tharunavignesh J for sharing.
The solution was to run the azure agent under proper account. Earlier my azure agent was running under some Network Service account, then I change it to the local account, then this cmd worked properly.
This other stack overflow link helped me get my visual studio installer project compiled with Azure DevOps pipelines. It is using yaml configuration instead of classic, but same steps / commands apply to both:
YAML Script for building Visual Studio Installer Projects using Azure DevOps
Basically the steps are:
Setup your variables to point to the tools
Download Nuget packages for your solution
Disable Out Of Process Builds command executed
Script task with the command line arguments to build your solution

Error on Azure DevOps pipeline for Windows form application

I am setting up build pipeline for Windows form application on azure devops with MSBuild arguments: /target:publish /p:ApplicationVersion="$(Build.BuildNumber)". I am getting error below but the transformation files should not be included in the build so I am not able to find why publish is looking for this file.
##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(5327,5): Error MSB3030: Could not copy the file "bin\app.DEV.config" because it was not found.

Build is successful on my local but not on vsts azure DevOps

I can successfully build my project on local. When I do via VSTS then build is not successful. I get an error message that a dll cannot be found in my sub project. And it is Rapportage.Logic. The missing dll is used by Rapportage.Logic
Does anyone know the reason?
Most of the time this type of error comes down to:
files present/edited on developer machine but not commited (usually the .csproj file)
subtle differences between Visual Studio build and MSBuild.
I would try the following:
copy the MSBuild command from Azure DevOps logs (the line containing MSBuild.exe)
change the paths in the command to match your dev environment (e.g d:\a\1\s to c:\code\myproject)
run this command
If this command fails with the same error as the build you the problem is a difference between MSbuild and Visaul Studio.
If it succeeds, you most likely have missed a commit.
Build is successful on my local but not on vsts azure DevOps
It depends on how you add ReportViewer references.
If you add the ReportViewer reference manually, you need add the ReportViewer reference to the solution/project folder, then add the reference from that folder. In this case, the path of references are not hard-coded paths. Besides, you need add those/this ReportViewer reference to the source control and submit to the Azure devops repos.
If you add the ReportViewer reference by nuget, you need add the nuget restore task to restore those nuget packages. I could see you are using nuget restore task from your build log (The second image.), but on the build definition, I did not see you have add that task (The 3rd, 4th images.). So, make sure you have restore those packages when you build on the Azure devops, and you could check the restore task if those nuget packages are restored.
Hope this helps.