I was recently trying to set up CI for a Cloud Service project. It builds fine in Visual Studio 2017 and 2019. However, when MSBuild is called to run it in Azure DevOps / ADO, I get the following build error:
"No file format header found"
Well that's annoying! Initially I thought it was a BOM issue, or an XML issue. Fixing that didn't work. Then I found some articles here about NuGet causing issues, but that wasn't it, either.
Here's my build step:
- task: VSBuild@1
displayName: 'Build Worker Cloud Service - INT'
inputs:
solution: '**\MyService.ccproj'
msbuildArgs: '/t:Publish /t:restore /p:SkipInvalidConfigurations=true /p:BclBuildImported=Ignore /p:OutputPath=bin\ /p:PublishDir=$(build.artifactstagingdirectory)\appcloud\Provisioning.QA /p:TargetProfile=QA'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration_Release)'
restoreNugetPackages: true
The issue was I was passing a Project file for the Solution file. By specifying the solution in the build step, then specifying the project file in the MSBuild arguments, the issue went away:
- task: VSBuild@1
displayName: 'Build Worker Cloud Service - INT'
inputs:
solution: '**\SomeSolution.sln' (<-- SPECIFY SOLUTION HERE)
msbuildArgs: '/t:Publish /t:restore /p:Project=MyService.ccproj (<-- SPECIFY PROJECT HERE) /p:SkipInvalidConfigurations=true /p:BclBuildImported=Ignore /p:OutputPath=bin\ /p:PublishDir=$(build.artifactstagingdirectory)\appcloud\SomeFolderName.QA /p:TargetProfile=QA'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration_Release)'
restoreNugetPackages: true
Note: YMMV on parameters above - don't just copy & paste, as those are some from my environment. Please alter as necessary. I've put arrows pointing to what I changed to resolve the issue.