DACPAC Deployment in VSTS - azure-devops

I want to create a dacpac file using VSTS. If I create a dacpac file and commit in VSTS to execute the scripts using Execute Azure SQL Tak:Dacpactask Azure database, we are unable to maintain the history of the changes. So I want to make the changes in SQL Project and move the project to VSTS. Do we have any task/way to generate a DACPAC file using sql project that we have in VSTS?. Finally I want to call that dacpac file using Execute Azure SQL Tak:Dacpactask to execute the scripts in Azure database

Refer to these steps below:
Refer to Grant’s answer to add project (not dacpac file) to source control and track changes
Create a new build definition
Add NuGet Tool Installer task (Version of NuGet.exe to install: 4.3.0)
Add NuGet task (Version:2.*; Command: restore; Path to solution, packages.config, or project.json: **/*sln)
Add Visual Studio Build task (Solution: [click … to select solution file]; Visual Studio Version: Visual Studio 2015; MSBuild Arguments: /p:OutDir=$(Build.ArtifactStagingDirectory))
Add Azure SQL Database Deployment task: (DACPAC File: $(build.artifactstagingdirectory)\**\SQLDatabase.dacpac)

In order to track changes you just have to connect your database project to whatever source control system you're using. It's a fundamental part of Visual Studio. You can just do that. Once it's connected to source control, you can then automate builds from the source control system using all the other Visual Studio tools. Here's an example that seems fairly complete. The next step is to integrate through the deployment processes in VSTS to automate the whole thing.

Related

Deploy dacpac as nuget

I'm trying figuring out how to handle dacpac files as nuget for our solution.
We have a huge database created and handled by a SSDT project that produces a dacpac.
We would like to create a pipeline in DevOps for creating a nuget package from that with a certain version, publishing it to Artifact. So everyone can download it and recreate the database locally.
is that possible?

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

Azure DevOps Pipeline not downloading reference

I'm relatively new to Azure DevOps, but I've already created 4 other pipelines that are working. I'm running into trouble with a build pipeline that is not pulling in NuGet references. I added the Task NuGet restore, but it's only getting some of the packages.
It works when I build in Visual Studio 2017. If I do a nuget restore from the command line, some of the packages are fetched. When I build, Visual Studio fetches the additional packages at the beginning of the build. Why is the NuGet restore task not fetching all of the packages? Why are the remaining packages fetched during the Visual Studio build, but not during the Azure DevOps build?
My project is old legacy ASP.NET that my boss wants automated. I'm talking the version of ASP.NET with .ASPX files that preceded MVC.
This is the error from the Azure DevOps build:
[error]WebApp\web.config(95,0): Error ASPCONFIG: Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
For this issue , first, make sure to select vs2017-win2016 agent when running the pipeline.
Secondly you can try to install the latest nuget.
Another possibility for your issue could be that some packages used by your project is not hosted in nuget.org. If part of the packages used locally are hosted in private server or local package source, the online Nuget Restore Task can't download the mssing packages. Please check your packages.config and project file to make sure all your packages are hosted in nuget.org.

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.

Deploying AzureDevOps Build Artifacts

I have a solution in Azure Devops. This is for Azure function. I am using the build pipeline to generate a artifact. This artifact I need to deploy it through powershell, I am using kudo API to deploy this.
https://$appName.scm.azurewebsites.net/api/zipdeploy
The issue is the format which Azure DevOps generates completely different from msdeploy in visual studio generates. When I deploy the zip file generated from vs it gets deployed correctly. Can I make Azure Devops to generate the Artifact same as visual studio
Adding more information as per comment
I am using Visual Studio Build Task to generate build and Publish task to publish artifact
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/visual-studio-build?view=azure-devops
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/publish-build-artifacts?view=azure-devops
The generated artifact with zip has a high depth something like "\publish\Content\D_C\a\1\s\src\aadsr\aadsr\obj\Release\net461\PubTmp\Out".
I just want the zip file should have content of Out folder, which I directly want to publish to a function APP