0
votes

Scenario -
I am trying to build and deploy project based on ASP.Net core2.0 on Ubuntu ec2 instance.

From VSTS -
I have created a Linux Private Build Agent on VSTS account.

Installing Linux Build Agent -
I have installed dotnet core 2.1.3 Also, successfully registered the Linux Private Agent on ec2.

Now,
From VSTS - Build and Release Tab-
Build Defination I have following tasks -

1) dotnet restore - This task gets executed successfully.

dotnet restore image

2) dotnet build - This task gets executed successfully.
dotnet build image

3) dotnet test - This task gets executed successfully.
dotnet test image

4) dotnet publish - This task creates published files for my all projects with .csproj.
publish task image

5) publish build artifact task publish artifact task

At the Task step 4, that means dotnet publish step- It publishes the published files at a path on Ubuntu private hosted agent ec2. For example, the path at which it publishes can be -
ubuntu@ip-111-11-1-111:/agent/_work/1/a
linux build agent artifact folder
If you have noticed in the "dotnet publish" task that, I am specifying the perticular .csproj file, still in the artifact "a" folder on linux build agent, it is publishing all source projects.
Also, note that I have some errors during this task, so I can only post the screen of "a" folder with this incomplete output.
For more information, I am also posting the screen for details from source "s" folder on build agent.
linux build agent -source folder

Please let me know, how can I publish only the particular project/source folder from VSTS ?

1

1 Answers

0
votes

You should use publish instead of custom in your step 4 (.NET Core task Command option):

enter image description here

Note: you should deselect Publish Web Projects option in .NET Core publish task.

For the reason why your step 4 published all the projects, it’s caused the option publishWebProjects set as true by default and the option can not be changed if you use custom command in .NET Core task. So it actually search for **/*.csproj pattern and ignore the project you specified.