1
votes

Im new to Azure Devops and I have existing app consisting of portal service(web app) and desktop app in .NET which is in one solution in visual studio. What is the best way to build/publish such structured solution?

When I select asp.net as step, it builds successfully and forms zip. But I dont think the .NET serilog app is added.

When I select .NET Desktop I get message at the end:

##[warning]Directory 'D:\a\1\a' is empty. Nothing will be added to build artifact 'drop'.

I would like to publish to On prem IIS server. Below is

trigger:
- main

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: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'
2
Why do you have to also deploy the console application to the target server? Does your web app depends on the console project in some aspects? If not, there's no need to deploy these two project in same artifact.LoLance
Hi Azm, is there any update for your issue? Could you share some details about which point are you being blocked by now?LoLance

2 Answers

1
votes

How to build pipeline with one .NET desktop app and one Web App in one sln file in Azure Devops

You can use asp.net template to create the build pipeline. Since it specifies solution: '**/*.sln' by default, the build task will build both projects.

1.To deploy Asp.net core project in IIS server, you can Publish Build Artifact of Web Project in build pipeline. And then use IIS Web App Manage task, IIS Web App Deploy tasks to deploy it.

2.As for the console project, as I know we don't have official recommended task to deploy desktop applications. Instead you can use Windows Machine File Copy task to copy the xx.exe to where you want.

(This task requires you to contain the xx.exe in build artifact, so you can keep outputs of two projects in same build artifact or have two build artifacts published for your two projects in build pipeline.)

1
votes

When you configure pipeline you can choose predefined template. For .NET Desktop app you should pick this one:

enter image description here

More details about this you will find here

It will create such YAML for you


trigger:
- main

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)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

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

Now to have your desktop application easily available for deployment you need to publish it as artifact.

And to build ASP.NET app (I assumed that this is you case) you need to use ASP/NET template, but actually you can use this one for both cases.

trigger:
- main

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

In terms of deployment it all depends where you want to deploy your app. But if you deploy to Azure App Service please check this Deploy a Web Deploy package (ASP.NET)

You question is lack of details thus it it difficult to give you best suited answer. But I hope this helps you.