2
votes

I'm trying to setup a CI/CD without much luck. My aim is to build a .net web project trough VSTS and deploy it to a AWS Beanstalk app.

Where am I so far?

Created a vsts-ci.yml file as following:

# ASP.NET
# Build and test ASP.NET web applications.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://docs.microsoft.com/vsts/pipelines/apps/aspnet/build-aspnet-4

pool:
  vmImage: 'VS2017-Win2016'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@0

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(Build.artifactStagingDirectory)"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

And I have a build definition like below:

build

With this my first step build runs correctly. Btw Agent pool is Hosted VS2017.

Then I have created a release pipeline like below:

release pipeline

And as the Stage 1 tasks (the part that runs after artifact step), I have following:

Release

I have hooked the build to a master branch commit, and hooked the release to a successful build, these triggerings works correctly. Though it fails. The problem is caused by not found artifact files probably because of wrong path inputs. But I don't know the correct versions.

After build finishes, it claims it created a .zip file containing the published version:

build-success

But after this, the release fails, only by saying no such file. I have tried many paths at Web Deploy Archive field, but none of them could find the zip file.

failed-release

The powershell task you see, I created it to check the paths, and what they have in them, and they are mostly empty.

One interesting thing I figured is, build puts the files in D:\a\1\a but release tasks try to look into D:\a\r1\a when I suffixed the Web Deploy Archive field with $(System.defaultWorkingDirectory) and $(Build.artifactStagingDirectory).

Another odd thing is that on release Download artifact stage, it says Linked artifact count: 0. Which I would expect to be something else.

enter image description here

What am I doing wrong here? If someone can guide me trough, I would appreciate.

Update: I've added "Publish Artifact: drop"

When Path to publish is "$(System.DefaultWorkingDirectory)/project-2-codes.zip"

Publishing build artifacts failed with an error: Not found PathtoPublish: D:\a\r1\a\project-2-codes.zip

When Path to publish is "$(System.DefaultWorkingDirectory)"

Publishing build artifacts failed with an error: Not found PathtoPublish: D:\a\r1\a\$(Build.ArtifactStagingDirectory)

2
You did add tasks to your build definition after you took the screenshot, right? Can you please describe how you configured your build tasks or publish the build log?renklus

2 Answers

3
votes

After a lot of head banging to the walls, I've found out the problem.

I was creating the build definition all wrong. I have used the default wizard thing, without noticing the custom designer (I don't think the text next to the link and the name of the link makes any sence).

build creation page

And it was creating an almost empty build definition. I didn't even understood what it was doing. Now, using the visual designer I can actually select a buil definition template with all the required build tasks in it. After creating the build correctly, everything worked just nice.

Here is the build definition I came up with:

build

And here is the beanstalk deployment task:

deployment

0
votes

You need to publish your build outputs as an artifact. Use the Publish Artifact task.