Our team is currently researching SonarCloud software. We originally used BitBucket pipeline, but found that it doesn’t support .Net, so we switched to Azure pipeline. However, we encountered problems during the trial process and need someone to assist in resolving confusion.
We have projects from .Net framework 4.0 to 4.8.
When running a .Net framework 4 project, the following error occurs.
Here is the azure pipeline, Is any setting wrong?
I saw the MSBuild using the latest version, is it possible to assign the MSBuild version?
Does Azure pipeline can support projects which is .net framework 4.0 to 4.8 ?
Is there a document that can be referenced?
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- checkout: self
fetchDepth: 0
- task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'select'
- task: SonarCloudPrepare@1
inputs:
SonarCloud: 'SonarCloud'
organization: 'dim-harrytest'
scannerMode: 'MSBuild'
projectKey: 'dim-harrytest_ecall_test'
projectName: 'eCall_Test'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: SonarCloudAnalyze@1
displayName: 'Run Code Analysis'
- task: SonarCloudPublish@1
displayName: 'Publish Quality Gate Result'
inputs:
pollingTimeoutSec: '300'
We tried to create a .NetCore project and successfully executed it and displayed the results on SonarCloud, but every time we make a pull request, the first Run Pipeline will always encounter the following error. But can work successfully if run again…
C:\hostedtoolcache\windows\dotnet\sdk\6.0.405\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(267,5): Error NETSDK1004: Assets file ‘D:\a\1\s\CSP\obj\project.assets.json’ not found. Run a NuGet package restore to generate this file.
Here is the azure pipeline.
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- checkout: self
fetchDepth: 0
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '6.0.x'
includePreviewVersions: true
- task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'select'
- task: SonarCloudPrepare@1
inputs:
SonarCloud: 'SonarCloud'
organization: 'dim-harrytest'
scannerMode: 'MSBuild'
projectKey: 'dim-harrytest_ecall_test'
projectName: 'eCall_Test'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: SonarCloudAnalyze@1
displayName: 'Run Code Analysis'
- task: SonarCloudPublish@1
displayName: 'Publish Quality Gate Result'
inputs:
pollingTimeoutSec: '300'