10
votes

I am trying to cerate Azure DevOps Build pipeline for WinForms desktop app and the problem is I can't publish the app and also can't cerate the build artifact.

I have created one WinForms desktop application and trying to create continuous integration (CI) pipeline in Azure DevOps.

I have selected the .NET Desktop template to configure the continuous integration (CI) pipeline. It is restoring NuGet and build solution successfully.

Now I want to publish the WinForms .NET Desktop application and generate the build artifact. I have tried it with the following task (as mention in https://developercommunity.visualstudio.com/content/problem/337714/can-build-code-but-release-pipeline-says-no-artifa.html)

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'

Following is my complete yml code:

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

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

- task: CopyFiles@2
  inputs:
    SourceFolder: '$(System.DefaultWorkingDirectory)\DesktopApp\bin\'
    Contents: '**'
    TargetFolder: '$(System.ArtifactsDirectory)'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'

It cannot generate artifact which I can download or use to release pipeline.

Needs help I cannot find how to publish the WinForms .NET Desktop application and generate the build artifact.

The main goal is to save publish app with setup and release folder of the desktop application at any location on my machine.

Can anyone help me out please?

1
Here's a quick question... are you creating or copying the build output to the Staging Directory? Can we see your complete build yaml file to see if you are outputting the Compiled output into Build.ArtifactStagingDirectory? Remember, the task PublishBuildArtifacts merely copies the files in that directory to the destination and associates it the the build summary.Antebios
@Reza Aghaei thanks for response I can copy the release folder from bin but I want to publish the WinForms desktop application and want that publish as artifact which I can download and save published app with setup of the desktop application at any location on my machine by the release pipeline.Sulay Joshi
@Antebios thanks for response I can copy the build from bin release folder which can be download from artifact but I want to publish the WinForms desktop application want that published as artifact. I have edited my question and added my yml code. I think I need to add publish task but I can not find publish task template or code for my yml.Sulay Joshi

1 Answers

5
votes

I want to publish the WinForms desktop application and want that publish as artifact which I can download and save published app with setup of the desktop application at any location on my machine by the release pipeline

If you want to publish the WinForms desktop application, so that you can download and save published app with setup of the desktop application at any location, you need to publish the output of publish, not the build.

So, to resolve this issue, you need provide the "/target:Publish" argument to MSBuild when it builds your project. Here is what this looks like in Azure Devops:

enter image description here

If the build fails with an error relating to an expired certificate or pfx file, see the other blog post on importing the required certificate on the build server at build-time, which involves adding one more “Import-PfxCertificate.ps1” build step before the MSBuild step.

Here is a great document show how to Continuously Deploy Your ClickOnce Application From Your Build Server.

Hope this helps.