Azure agent: where to find SqlPackage.exe - azure-devops

I use a Microsoft hosted agent for building and verifying my project including an sql project.
On this azure agent I need to find the SqlPackage.exe file to call it via a powershell task. I know that there is the SqlServerDacpacDeployment task but that does not satisfy my needs. I also know that the SqlPackage.exe has to be somewhere because the SqlServerDacpacDeployment task can run without the failure that it can not find the SqlPackage.exe file.
Does anybody know where it is installed on an agent with vmImage: 'VS2017-Win2016' or how to located it?

For VS2017-Win2016 agent:
You can find the SqlPackage.exe under path C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\150\
This is also the installation path in local machine. For devops, you can use CMD task with content below to check whether the SqlPackage.exe exists there:
C:
cd C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\150\
dir
Check the log and you'll find:
And for Windows-2019, just use 2019 instead of 2017 in the path above.

Related

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

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

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):

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.

Post Build event that works on both Azure DevOps and Local PC

I have a VS2017 solution that Builds both locally and also on Azure DevOps.
I now need to run a Post Build script to run an EXE. I have this working on my local machine, but I guess there will be an issue with the Path to the EXE which has been added to the DevOps Library.
Note. The EXE is all installed on DevOps and runs fine from a Command Line Task - I just need it to run as a post build on one of the projects so that this project is ready to be packaged in the Installer SetUp project. (During a full Solution build).
This represents the Local Post Build script - How do I handle this on Azure, where the path will be different?
"C:\Program Files (x86)\{dir}\{app}.exe" -file "$(ProjectDir){file.txt}"
Any help appreciated. Thanks!
This represents the Local Post Build script - How do I handle this on
Azure, where the path will be different?
$(ProjectDir) is msbuild property, so it works on both Azure DevOps and Local PC. You only need to pay attention to the {dir} of the xx.exe.
My suggestion is to put the exe in solution folder (where the xx.sln file exists), then you can use script like "$(SolutionDir)\{app}.exe" -file "$(ProjectDir){file.txt}". The $(SolutionDir) and $(ProjectDir) can be recognized by msbuild. (It works for both local pc and online devops.)
Or you can put the xx.exe under root directory of your git repo, then use $(System.DefaultWorkingDirectory) as the path of your xx.exe, but it only works for online devops, it can't work on local PC. (Not recommended)

VSTS CI CD for desktop apps

How can I achieve CD (Continuous Delivery) for winform applications in VSTS (Visual Studio Team Services)? Currently this is what I have in my Visual Studio Solution file
1) A winform project
2) A Windows setup and Deployment project
So every time I build a winform project, I do the following steps (and I need CI / CD for exactly these)
1) Build Setup and Deployment project, which takes Build output of Winform project and creates and EXE / MSI
2) I take this MSI file and use NSIS to embed it inside EXE
3) I run SIGNTOOL from command prompt and digital sign the EXE
4) I upload this signed EXE to my website
Now how can I use CI / CD pipeline to automate the above or is it not possible for my case? I am confused. I can't find any material for winforms, all are for web apps.
Thanks
You will obviously need some sort of desktop deployment strategy. The easiest is to be using xcopy. Other alternatives include frameworks like ClickOnce, Windows Installer or Squirrel to name a few. I have a number of corporate apps that use Clickonce that I have deployed using vsts.
Now I am unable to understand how will VSTS help me with this?
Use VSTS to build the software first and include additional tasks to package your app. In my case, I use devenv.exe to generate ClickOnce packages, but you can include custom tasks by using powershell. The artifact of the build should now be the "packaged app".
Then use the VSTS deployment to copy the "package" to some kind of hosting server from where your users can download the package. That could be either a web server or a fileserver or any location appropriate for your deployment strategy.
In this context, VSTS is an orchestration tool. It helps to trigger actions for you.
See Deploy an agent on Windows to see how to setup an on-premise agent.
To build and deploy the way as you used in VSTS, you can use below steps:
Create a repository (Git or TFVC) and push your solution in the repository.
Add build/release definitions.
With CI build, enable the Continuous Integration in Triggers Tab. With CD deploy, enable Continuous deployment trigger in Pipeline Tab. The process for CI build and CD deploy, you can refer CI/CD.
Add related tasks in your build/release definition.
Build VS Installer task: build setup project with msi file.
Nsis Build Task: embedded msi file in exe.
Command Line task: to execute the signtool command. Since Hosted agent has not signtool.exe, so you should use private agent which has the signtool.exe on the machine.
Copy files task, Copy Files Over SSH task or Windows Machine File copy task: upload the file exe to your web server.