I have a .Net Framework 4.8 application with multiple projects in the solution. The main project(.csproj) - "Project A" has Platform target as 'x86' for both Debug and Release configurations, whereas other projects have 'Any CPU' as platform targets for both Debug and Release configurations.The solution builds (compiles) fine in Visual Studio, but when I am trying to create and run YAML build pipeline using the VSBuild@1 task, it's failing with errors. The errors are thrown by a test project which has 'project A' as a reference, the errors are thrown as if the "Project A" is not added as a reference. But the project A is added as reference to the test project.
By the way am new to YAML pipelines, but I believe the YAML pipeline is fine for .net app.
The errors thrown are all of type: Error CS0234: The type or namespace name 'MessageHandler' does not exist in the namespace 'xx.xx.xx.ProjectA' (are you missing an assembly reference?) "Build-Windows" is a windows self-hosted agent that's a Windows Server 2019 OS. I have tried a lot to resolve, but no luck. What am I missing? Any help would be very much appreciated!! My YAML pipeline looks like this:
trigger:
- none
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
pool: Build-Windows
steps:
- task: NuGetToolInstaller@1
displayName: ⬇ NuGet - Install
inputs:
versionSpec:
checkLatest: true
- task: NuGetCommand@2
displayName: NuGet - Restore
inputs:
command: 'restore'
restoreSolution: '$(solution)'
feedsToUse: 'config'
nugetConfigPath: NuGet.Config
- task: VSBuild@1
displayName: Build
inputs:
solution: '$(solution)'
msbuildArgs: '/p:OutDir=$(Build.ArtifactStagingDirectory)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
clean: true
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts@1
displayName: ⬆ Publish Artifacts
inputs:
ArtifactName: Package
TargetPath: $(Build.ArtifactStagingDirectory)
I tried changing the target platforms and changed YAML build pipeline multiple times but no luck.
There could be any of a few problems going on. It's possible that the "clean" build machine environment leads to problems that you aren't seeing on your local box.
Check your build configuration:
And see if the x86 is being built when the project is under
Any CPU
config.If it's not, then what's likely happening is that you built
x86
at some point and building theAny CPU
platform is using the previously built version. What you'll need to do in the pipeline is make sure you build thex86
version first, then build theAny CPU
version.