I’m trying to add third new agent to default pool and get an error message on NuGet restore task during testing. The error is “##[error]connect ECONNREFUSED 18.104.22.168:443”. What did I do wrong?
2019-06-23T16:12:22.1309391Z ##[section]Starting: NuGet restore
2019-06-23T16:12:22.1465660Z Task : NuGet Restore
2019-06-23T16:12:22.1465660Z Description : Restores NuGet packages in preparation for a Visual Studio Build step.
2019-06-23T16:12:22.1465660Z Version : 1.0.1
2019-06-23T16:12:22.1465660Z Author : Microsoft Corporation
2019-06-23T16:12:22.1465660Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613747)
2019-06-23T16:12:23.1623101Z [command]C:\Windows\system32\chcp.com 65001
2019-06-23T16:12:23.1623101Z Active code page: 65001
2019-06-23T16:12:24.2466118Z ##[error]connect ECONNREFUSED 22.214.171.124:443
2019-06-23T16:12:24.2466118Z ##[section]Finishing: NuGet restore
TFS 2019, Visual Studio 2019, Build Server Agents Version 2.122.1 with Proxy, Build Definition with NuGet Restore Version 1.0.1
Most likely the problem is with connection to outside world. But in this case, it was because it’s missing NuGet.exe file under agent folder \_work\_tool\NuGet\4.0.0\x64\nuget.exe. To make sure you have this file, please check under your TFS Agent folder under _work\_tool\NuGet\4.0.0\x64. Please follow below instructions to check if web proxy setup correctly.
- Open File Explorer and browse to where you install TFS Agent
- First locate a proxy file named: .proxy (you may need to show hidden file to see it)
- Open .proxy file with Notepad and make sure the web proxy gateway name is correct with http/https prefix and port number
- Second, check \externals\vstshost\LegacyVSTSPowerShellHost.exe.config file for web proxy settings
- Open LegacyVSTSPowerShellHost.exe.config and check if you have defaultProxy attribute under system.net section
<proxy proxyaddress="http://your.proxy.com:8080" bypassonlocal="true" />
- Third, check if you have nuget.exe install under agent folder \_work\_tool\NuGet\4.0.0\x64\
- Four (optional), sync \_work\_tasks folder with other agent build server so all build servers have same packages installed
- Restart the VSTS Agent service and try to build again
To make sure build server is using proxy to connect to external source, check with firewall log.
Create Build Definition
I would like to setup a build definition that will run when I check in my application and database projects. Then I want my artifact to automatically release to production environment. Where do I start?
Team Foundation Server (TFS) 2017, Visual Studio (VS) 2017, Build Server (BS) 2017, ASP.Net Project, SQL Server 2016
For Build definition instruction, please refer to TFS Build and Release Management Definition Automation Tutorial (Part 1). Here are step-by-step instructions on how to setup release definition that will publish code and database automatically. This release definition uses artifact created by build definition previously with different build configurations to publish to different environments.
- Create a new Release definition by clicking on “Releases” tab and “+ New definition” link.
Or by clicking on “Releases” tab, then click on “+” dropdown and select “Create release definition” link.
- Choose “Empty” template and click “Next”.
- Select the correct build definition from “Source (Build definition)” dropdown that created previously on part 1. Click on checkbox for “Continuous deployment …”. Then click on “Create” button to create a new release definition.
- Rename your Release definition and Environment name
- Click on “Artifacts” tab and verify that the source is correct from the build you created on part 1.
- Click on “Triggers” tab and verify that “Set trigger on artifact source” dropdown is correctly selected.
- Click on “Environments” tab and “+ Add tasks” link to add a task. Do not click on dropdown and select “Add an agent phase” unless you are doing something else.
- Click on “Utility” tab, scroll down to “PowerShell” task and click on “Add” button twice to add two PowerShell tasks.
- Rename to “App Deployment Script” and enter script path and arguments as shown below. Make sure AppPackageV126.96.36.199.ps1 Custom PowerShell script is accessible by build server.
Script Path: \\put-this-ps-on-your-build-server-share\AppPackageV188.8.131.52.ps1
Arguments: $(my_Target_Path1) $(my_Encrypt_Cfg) $(my_Cleanup_Target) $(my_Source_Path)
- Rename to “Database Deployment Script” and enter script path and arguments as shown below. Make sure SqlPackageV184.108.40.206.ps1 Custom PowerShell script is accessible by build server.
Script Path: \\put-this-ps-on-your-build-server-share\SqlPackageV220.127.116.11.ps1
Arguments: $(my_Source_DACPAC_File) $(my_Publish_Profile)
- Next is to convert PowerShell task to Task Group so that it can be called easily with variables. To convert to Task Group, right click on “App Deployment Script” and select “Create task group”.
- Enter “App Deployment Task” on Name field and click on “Create”.
- As you can see below, it’s using “App Deployment Task” task group with variables on the right hand side. By doing this, you can deploy your code to multiple location with new “App Deployment Task” task found under “Add tasks” link.
Custom PowerShell Script (PS) Variable Description:
my_Target_Path1 = Target folder (i.e., web server UNC path: \\webserver1\demo)
my_Source_Path = Source folder (i.e., build artifact wwwroot folder: $(System.DefaultWorkingDirectory)\Project_Demo_Build\drop\[Debug]\wwwroot)
my_Encrypt_Cfg = Encrypt web.config sections (0 = disable encrypt; 1 = enable encrypt (default))
my_Cleanup_Target = Delete target folder (0 = disable delete; 1 = enable delete (default))
- Do the same for “Database Deployment Task” from step 11 to 13 and you will end up with “Database Deployment Task” task group as shown below.
Custom PS Variable Description:
my_Source_DACPAC_File = Source DACPAC database file (i.e., build artifact dbroot folder: $(System.DefaultWorkingDirectory)\Project_Demo_Build\drop\[Debug]\dbroot\Proj.Demo.Database.dacpac)
my_Publish_Profile = Predefined publish profile for database (i.e., $(System.DefaultWorkingDirectory)\Project_Demo_Build\drop\[Debug]\dbroot\Proj.Demo.Database.[Debug].publish.xml)
- Click on “Run on agent” link to select a deployment queue/pool.
- In case you wonder, Task Groups can be found by clicking on “Task Groups” link as shown below.
- Click on “Save” link to save your release definition.
- If you see “The model version ‘2.9. is not support.”, this could be the wrong version of SQLPackage.exe is being used. Make sure to use 2017 SQLPackage.exe.