How do I use Azure DevOps pipeline to build an ASP NET web site

0 votes

I am working with an older code and attempting to build an ASP.NET website (no .csproj files). I've created a pipeline for ASP.NET added some tasks to my .yml:

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

trigger:
- master

pool:
  vmImage: 'windows-latest'

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

steps:
- task: NuGetToolInstaller@1

- 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)'

- task: PublishPipelineArtifact@1
  inputs:
    targetPath: '$(Pipeline.Workspace)'
    artifact: 'drop'
    publishLocation: 'pipeline'

However, when I run the pipeline, it fails on the VSBuild task: VSBuildResults

I think the problem is in line 18 where the -p ..\BOMViewer\ is specifying a directory that doesn't exist.

Do I need to follow DJ Grossman's solution later?

How to specify -p \BOMViewer instead of the above?

I changed solution to .publishproj from .sln in my YAML . But VSBuild doesn't like the change: enter image description here

Mar 23, 2022 in Other DevOps Questions by Kichu
• 19,040 points
3,119 views

1 answer to this question.

0 votes

For an ASP.NET Website, you should use website.publishproj file instead of the .sln file to build it. Because Website projects are published, and not built (and that's why the .publishproj files, in this case, work similarly to .csproj files).
Try to modify the value of your $solution variable to **\*.publishproj instead of **\*.sln.

Learn how to create a new build pipeline in Azure DevOps today! Build, test, and deploy your code with ease using our step-by-step guide. Start now to accelerate your software delivery and boost team productivity.

answered Mar 25, 2022 by narikkadan
• 63,600 points

Related Questions In Other DevOps Questions

0 votes
0 answers

How do I add the azure-devops commands to the Azure CLI in an offline on-premise server?

I wanted to add the azure-DevOps extension to the Azure ...READ MORE

Apr 19, 2022 in Other DevOps Questions by Kichu
• 19,040 points
564 views
0 votes
0 answers

How to YML Schedule build in Azure DevOps Pipeline

I have an existing pipeline created in ...READ MORE

Mar 28, 2022 in Other DevOps Questions by Kichu
• 19,040 points
1,321 views
0 votes
0 answers

Basic Azure DevOps flow for ASP .Net

I have a custom build script and ...READ MORE

Apr 20, 2022 in Other DevOps Questions by Kichu
• 19,040 points
510 views
0 votes
0 answers
0 votes
1 answer

How do I update Node.js?

Use Node Version Manager (NVM). This helps you ...READ MORE

answered Apr 29, 2022 in Other DevOps Questions by narikkadan
• 63,600 points
716 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP