3

I am working with an older code and attempting to build an ASP.NET website (no .csproj files).

I've created an 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://learn.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

The problem appears to be on line 18 where the -p ..\BOMViewer\ is specifying a directory that doesn't exist.

I may need to follow DJ Grossman's solution later: Can Azure DevOps Pipelines build an ASP.NET Web Site?

But for now, how can I specify -p \BOMViewer instead of the above?

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

Final

My .gitignore was ignoring the .publishproj file. Changed that and it worked like charm, per @YashGupta's answer below.

ben.kansas
  • 71
  • 7
  • Not sure if this matters, but the official documentation of `VSBuild@1` task shows that the path to `.sln` file should be specified with a backward slash: `**\*.sln` , and not with a forward slash: `**/*.sln` like you're using in your YAML. Link: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/visual-studio-build?view=azure-devops – Yash Gupta Aug 15 '21 at 07:06
  • @YashGupta thanks for looking at this. I changed that in my YAML, but it had no effect. – ben.kansas Aug 16 '21 at 14:16
  • Maybe try building your website using `MSBuild@1` task instead of `VSBuild@1` task since VSBuild task is not liking those changes? Worth a shot. – Yash Gupta Aug 17 '21 at 05:22
  • @YashGupta,I tried using `MSBuild@1`, but I didn't get any different results. – ben.kansas Aug 17 '21 at 16:43
  • @YashGupta since it is a website, do I need to create a publish profile in the solution itself for a web deploy or a web deploy package (eventually this will be deployed to an on-prem IIS)? – ben.kansas Aug 17 '21 at 16:46
  • Currently, the publish is to a FolderProfile, which is then copied to the IIS server manually. – ben.kansas Aug 17 '21 at 16:46
  • 1
    Don't include screenshots of errors. Include the **text**. – Daniel Mann Aug 17 '21 at 19:11
  • Ah damn! The gitignore! Well, glad that you got it all fixed. Cheers! – Yash Gupta Aug 18 '21 at 05:41
  • @DanielMann, ok thanks. I will do that in the future. – ben.kansas Aug 18 '21 at 17:16

1 Answers1

2

As per my understanding, for an ASP.NET Website you should be using website.publishproj file instead of the .sln file to build it. Because Website projects are actually published, and not built (and that's why the .publishproj files in this case work similar to .csproj files).

Try modifying the value of your $solution variable to **\*.publishproj instead of **\*.sln.

Yash Gupta
  • 1,807
  • 15
  • 21
  • could you please help me to specify the path of zip(of build generated by artifact) to feed into an azure web app. – krr Dec 13 '22 at 15:15