0

Trying to get a build pipeline running in azure devops 2019 on premise with the following azure-pipelines.yaml

steps:
- task: MSBuild@1
  inputs:
    solution: 'solution.sln' 
    msbuildVersion: 16.0

But one compile error keeps popping up.

Error CS1043: { or ; expected

It's on this line:

public List<CountryZipCode> ZipCodeExceptions { get => _zipCodeExceptions; 
                                                set => _zipCodeExceptions = value; }

How do you pick a version in the msbuild agent? Or do I need to install something?

Serve Laurijssen
  • 9,266
  • 5
  • 45
  • 98
  • Have you tried setting the C# language version: https://stackoverflow.com/questions/46419760/using-c-sharp-7-1-with-msbuild – mortb Jul 01 '20 at 14:38
  • Try with `msbuildArguments: /property:langversion=latest` – mm8 Jul 01 '20 at 15:03

2 Answers2

0

MSBuild documentation suggests you use Visual Studio Build task to build solution.

https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/msbuild?view=azure-devops

If you are building a solution, in most cases you should use the Visual Studio Build task. This task automatically:

  • Sets the /p:VisualStudioVersion property for you. This forces MSBuild to use a particular set of targets that increase the likelihood of a successful build.

  • Specifies the MSBuild version argument.

In Visual Studio Build task, the property vsVersion 'latest' (default value) should fix the build.

https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/visual-studio-build?view=azure-devops

Nouman
  • 591
  • 6
  • 14
0

It turns out visual studio build tools 2019 needed to be installed.

https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019

Serve Laurijssen
  • 9,266
  • 5
  • 45
  • 98