When using the RM tool to deploy dacpacs as explained in “Deploy dacpac with MSDeploy in VS Release Management”, below error might occur.
Info: Adding MSDeploy.dbDacFx (MSDeploy.dbDacFx).
Info: Adding database (server=tcp:mydb.database.windows.net,1433;database=DeployTest;user id=
e;trustservercertificate=False;connection timeout=30)
Info: Initializing deployment: Pending.
Info: Analyzing deployment plan: Pending.
Info: Updating database: Pending.
Info: Creating deployment plan: Pending.
Info: Verifying deployment plan: Pending.
Info: Deploying package to database: Pending.
Info: Creating deployment plan: Running.
Info: Initializing deployment: Running.
Info: Initializing deployment (Start)
Info: Initializing deployment: Faulted.
Info: Initializing deployment (Failed)
Info: Creating deployment plan: Faulted.
Info: Verifying deployment plan: Faulted.
Info: Deploying package to database: Faulted.
Error Code: ERROR_EXECUTING_METHOD
More Information: Could not deploy package.
Unable to connect to target server.
Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_EXECUTING_METHOD.
Error: Could not deploy package.
Error: Unable to connect to target server.
This is without much information and a generic error, might require tearing your hair out a lot, trying to resolve.
How to resolve
This could be easily a firewall blocking access to your SQL server, or firewall not allowed IP for your Azure database server. Fix could be easy as adding the required firewall exceptions.
Thursday, 31 March 2016
Friday, 25 March 2016
Build C# 6 Syntax with TFS 2013.4 Build Services
If you are using VS 2015 with C# 6 syntax and try to build it with, TFS 2013.4 (build agent installed with VS 2015 Update1 enterprise) you might run into issues like shown below.
The name 'nameof' does not exist in the current context
This error occurs, since TFS 2013.4 build template is using, msbuild 12.0. To let the TFS build to use msbuild 14.0, you can provide msbuild argument /ToolsVersion switch (or /tv, for short), in TfvcTemplate.12.xaml build process template.
/tv:14.0
With this the previous error solved but now it runs into below issue.
TF900547: The directory containing the assemblies for the Visual Studio Test Runner is not valid ''
To solve this install VS 2013 in build agent. It solves the problem.
Tests in here fail, but that is nothing to do with build. Tests are not properly written.
You might run into below issue as well.
Unhandled Exception: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
at LibGit2Sharp.Core.NativeMethods.LibraryLifetimeObject..ctor()
at LibGit2Sharp.Core.NativeMethods..cctor()
--- End of inner exception stack trace ---
at LibGit2Sharp.Core.NativeMethods.RemoveHandle()
at LibGit2Sharp.Core.NativeMethods.LibraryLifetimeObject.Finalize()
This is discussed in below links and you can solve using different techniques described in them.
https://social.msdn.microsoft.com/Forums/en-US/5a0d1950-1367-41a6-9171-676a0d0e93c1/tfs-online-getted-checkin-build-failures-vs-online-tfs-online-team-need-to-look-into-it?forum=TFService
http://stackoverflow.com/questions/29286052/tfs-2013-throws-lib2gitsharp-error-during-build-deploy-intermittent
The name 'nameof' does not exist in the current context
This error occurs, since TFS 2013.4 build template is using, msbuild 12.0. To let the TFS build to use msbuild 14.0, you can provide msbuild argument /ToolsVersion switch (or /tv, for short), in TfvcTemplate.12.xaml build process template.
/tv:14.0
With this the previous error solved but now it runs into below issue.
TF900547: The directory containing the assemblies for the Visual Studio Test Runner is not valid ''
To solve this install VS 2013 in build agent. It solves the problem.
Tests in here fail, but that is nothing to do with build. Tests are not properly written.
You might run into below issue as well.
Unhandled Exception: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
at LibGit2Sharp.Core.NativeMethods.LibraryLifetimeObject..ctor()
at LibGit2Sharp.Core.NativeMethods..cctor()
--- End of inner exception stack trace ---
at LibGit2Sharp.Core.NativeMethods.RemoveHandle()
at LibGit2Sharp.Core.NativeMethods.LibraryLifetimeObject.Finalize()
This is discussed in below links and you can solve using different techniques described in them.
https://social.msdn.microsoft.com/Forums/en-US/5a0d1950-1367-41a6-9171-676a0d0e93c1/tfs-online-getted-checkin-build-failures-vs-online-tfs-online-team-need-to-look-into-it?forum=TFService
http://stackoverflow.com/questions/29286052/tfs-2013-throws-lib2gitsharp-error-during-build-deploy-intermittent
Tuesday, 22 March 2016
Deploy dacpac with MSDeploy in VS Release Management
To deploy a dacpac against a target database, MSDeploy can be used. In powershell, following command allows to deploy a dacpac.
Invoke-Expression "& 'WebDeployFolderPath\msdeploy.exe' --% -verb:sync -source:dbDacFx=`'SourceDACPAC`' -dest:dbDacFx=`'DestinationDBConnection`',commandTimeout=100" -Verbose -ErrorAction "Stop"
Example
.\DeployDacpacMSDeploy.ps1 -WebDeployFolder "C:\Program Files (x86)\IIS\Microsoft Web Deploy V3" -SourceDACPAC "C:\temp\MyDb.dacpac" -DestinationDBConnection "Server=tcp:qa-db.database.windows.net,1433;Database=mydb;User ID=dbadmin@qa-db;Password=pwd;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30" -CommandTimeout 100
A poweshell script can be developed, to use in a Release Management tool.
Using this poweshell script a tool in RM can be created as shown below.
Using the tool, create an action component.
This component can be used in a release template.
Database updates can be pushed to Azure SQL or any other target SQL server.
Invoke-Expression "& 'WebDeployFolderPath\msdeploy.exe' --% -verb:sync -source:dbDacFx=`'SourceDACPAC`' -dest:dbDacFx=`'DestinationDBConnection`',commandTimeout=100" -Verbose -ErrorAction "Stop"
Example
.\DeployDacpacMSDeploy.ps1 -WebDeployFolder "C:\Program Files (x86)\IIS\Microsoft Web Deploy V3" -SourceDACPAC "C:\temp\MyDb.dacpac" -DestinationDBConnection "Server=tcp:qa-db.database.windows.net,1433;Database=mydb;User ID=dbadmin@qa-db;Password=pwd;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30" -CommandTimeout 100
A poweshell script can be developed, to use in a Release Management tool.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
param( [Parameter(mandatory=$true)] [string]$WebDeployFolder, [Parameter(mandatory=$true)] [string]$SourceDACPAC, [Parameter(mandatory=$true)] [string]$DestinationDBConnection, [Parameter(mandatory=$true)] [string]$CommandTimeout ) $ErrorActionPreference = "Stop" Invoke-Expression "& '$WebDeployFolder\msdeploy.exe' --% -verb:sync -source:dbDacFx=`'$SourceDACPAC`' -dest:dbDacFx=`'$DestinationDBConnection`',commandTimeout=$CommandTimeout" -Verbose -ErrorAction "Stop" | Out-Host if ($lastexitcode -ne 0) { throw "Dacpac deploy failed." } |
Using the tool, create an action component.
This component can be used in a release template.
Database updates can be pushed to Azure SQL or any other target SQL server.
Wednesday, 9 March 2016
Run xUnit Unit Tests for (dnx)ASP.Net 5 with VS Team Services Build
To run the xUnit unit tests developed for ASP.Net 5 (ASP.Net Core 1.0 now), you need to setup a powershell step/task. Setting up a build with VS Team Services, for ASP.Net 5 is explained here.
First thing we need is a powershell script, which can runt xUnit tests, in VS Team Services build. (Hardcoded paths and project names in the script)
Set-ExecutionPolicy unrestricted -Scope CurrentUser -Force $VerbosePreference = "continue" $ErrorActionPreference = "Continue" &{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))} $globalJson = Get-Content -Path $PSScriptRoot\..\..\EventBooking\global.json -Raw -ErrorAction Ignore | ConvertFrom-Json -ErrorAction Ignore if($globalJson) { $dnxVersion = $globalJson.sdk.version } else { Write-Warning "Unable to locate global.json to determine using 'latest'" $dnxVersion = "latest" } & $env:USERPROFILE\.dnx\bin\dnvm install $dnxVersion -Persistent $dnxRuntimePath = "$($env:USERPROFILE)\.dnx\runtimes\dnx-clr-win-x86.$dnxVersion" dnx -p $PSScriptRoot\..\..\EventBooking\BookMyEvents.UnitTests test
We have to make sure test results are available to publish in the build. for that we can change the test project .json to create a results xml.
Next add a powershell script task/step to the build. Set the script to execute and let it continue on error, to make sure, it will not break the build on a test failure.
To publish the results, use “Publish Test Results” step. Set the test results xml file name specified in the project .json, for the results files. Select the Test result format as XUnit.
Once a build queues it executes the test and publish the results.
When there are multiple tests running in the build, a detailed test report helps to identify which tests fail.
Subscribe to:
Posts (Atom)
Popular Posts
-
Dynamic block allows to create nested multi level block structures in terraform code. Conditional usage of such blocks are really useful in...
-
In Azure DevOps YAML pipelines there are several functions available for you to use. replace is such a useful function, which you can use t...
-
We have discueed, that we have to use an environment variable to handle input parameter default values, if we are using trigger for workflo...
-
Adding Azure Container Registry (ACR) service connection to Azure DevOps is really simple as described in " Create Service Connection ...
-
Some times a silly mistake can waste lot of time of a developer. The exception “System.IO.IOException: The response ended prematurely.” whil...