Sunil Krishna kanth
Sunil Krishna kanth

Reputation: 1

Unable to build .Net MAUI Windows application in Azure DevOps Pipeline

I'm trying to build my .Net MAUI application(which targets Android and Windows) in Azure Devops Pipeline. My Android pipeline is building successfully. However, Windows is giving below error.

error CS5001: Program does not contain a static 'Main' method suitable for an entry point

I'm using .NetCoreCLI@2 task to build the project. Below is my yaml configuration for the same:

- task: DotNetCoreCLI@2
  displayName: 'Build MAUI Application'
  inputs:
    command: publish
    publishWebProjects: false
    projects: IFSINTEGRATOR/IFSINTEGRATOR.sln
    arguments: '-c Release -f net7.0-windows10.0.19041.0'
    zipAfterPublish: false
    modifyOutputPath: false

I'm able to successfully build in my local machine withthe same command dotnet publish -c Release -f net7.0-windows10.0.19041.0 in Developer Command Prompt for VS2022.

Can you help me in successfully building the Windows app in the pipeline by resolving the above issue?

I tried multiple tasks like Powershell, DOTNETCORECLI etc to build the project and all are throwing the same error.

Upvotes: 0

Views: 279

Answers (1)

Bright Ran-MSFT
Bright Ran-MSFT

Reputation: 13919

You can try to use the CmdLine@2 task to run the dotnet commands in your pipeline like as below.

jobs:
- job: build
  steps:
  - task: UseDotNet@2
    displayName: 'Use .NET 7'
    inputs:
      version: 7.x

  - script: 'dotnet workload restore IFSINTEGRATOR/IFSINTEGRATOR.sln'
    displayName: 'Install workloads'

  - script: 'dotnet publish IFSINTEGRATOR/IFSINTEGRATOR.sln -c Release -f net7.0-windows10.0.19041.0'
    displayName: 'Build MAUI Application'

Upvotes: 0

Related Questions