简体   繁体   中英

How to Dotnet Publish from VSTS with Private Linux Hosted Build Agent?

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恢复映像

2) dotnet build - This task gets executed successfully.
dotnet构建映像

3) dotnet test - This task gets executed successfully.
点网测试图

4) dotnet publish - This task creates published files for my all projects with .csproj.
发布任务图片

5) publish build 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神器文件夹
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-源文件夹

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

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

在此处输入图片说明

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM