Dotnet build fails in git actions

I have an headached with an issue when I use github actions the project try to do the build of the project,
becasuse needs this dll \MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets
but this doesn’t exists in the git machine.

I remember I had to install visual studio 2015 because the new versions of VS didn’t compatible and the scan doesn’t worked without it.

also this is a.net Framework 4.8

Run .\.sonar\scanner\dotnet-sonarscanner begin /k:"Canon_Creators" /d:sonar.login="***" /d:sonar.host.url="***"
SonarScanner for MSBuild 5.9.2
Using the .NET Core version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
16:02:57.575  Updating build integration targets...
16:02:57.793  Fetching analysis configuration settings...
16:02:58.172  Provisioning analyzer assemblies for cs...
16:02:58.172  Installing required Roslyn analyzers...
16:02:58.641  Provisioning analyzer assemblies for vbnet...
16:02:58.641  Installing required Roslyn analyzers...
16:02:58.672  Pre-processing succeeded.
MSBuild version 17.4.0+18d5aef85 for .NET
D:\a\CanonRepSitefinity\CanonRepSitefinity\CanonV2\SitefinityWebApp.csproj(17,3): warning MSB4011: "C:\Program Files\dotnet\sdk\7.0.101\Current\Microsoft.Common.props" cannot be imported again. It was already imported at "D:\a\CanonRepSitefinity\CanonRepSitefinity\CanonV2\SitefinityWebApp.csproj (3,3)". This is most likely a build authoring error. This subsequent import will be ignored. 
D:\a\CanonRepSitefinity\CanonRepSitefinity\CanonV2\SitefinityWebApp.csproj(17,3): warning MSB4011: "C:\Program Files\dotnet\sdk\7.0.101\Current\Microsoft.Common.props" cannot be imported again. It was already imported at "D:\a\CanonRepSitefinity\CanonRepSitefinity\CanonV2\SitefinityWebApp.csproj (3,3)". This is most likely a build authoring error. This subsequent import will be ignored. 
  Determining projects to restore...
  Nothing to do. None of the projects specified contain packages to restore.
D:\a\CanonRepSitefinity\CanonRepSitefinity\CanonV2\SitefinityWebApp.csproj(17,3): warning MSB4011: "C:\Program Files\dotnet\sdk\7.0.101\Current\Microsoft.Common.props" cannot be imported again. It was already imported at "D:\a\CanonRepSitefinity\CanonRepSitefinity\CanonV2\SitefinityWebApp.csproj (3,3)". This is most likely a build authoring error. This subsequent import will be ignored. 
D:\a\CanonRepSitefinity\CanonRepSitefinity\CanonV2\SitefinityWebApp.csproj(2085,4): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.

Build FAILED.

D:\a\CanonRepSitefinity\CanonRepSitefinity\CanonV2\SitefinityWebApp.csproj(17,3): warning MSB4011: "C:\Program Files\dotnet\sdk\7.0.101\Current\Microsoft.Common.props" cannot be imported again. It was already imported at "D:\a\CanonRepSitefinity\CanonRepSitefinity\CanonV2\SitefinityWebApp.csproj (3,3)". This is most likely a build authoring error. This subsequent import will be ignored. 
D:\a\CanonRepSitefinity\CanonRepSitefinity\CanonV2\SitefinityWebApp.csproj(17,3): warning MSB4011: "C:\Program Files\dotnet\sdk\7.0.101\Current\Microsoft.Common.props" cannot be imported again. It was already imported at "D:\a\CanonRepSitefinity\CanonRepSitefinity\CanonV2\SitefinityWebApp.csproj (3,3)". This is most likely a build authoring error. This subsequent import will be ignored. 
D:\a\CanonRepSitefinity\CanonRepSitefinity\CanonV2\SitefinityWebApp.csproj(17,3): warning MSB4011: "C:\Program Files\dotnet\sdk\7.0.101\Current\Microsoft.Common.props" cannot be imported again. It was already imported at "D:\a\CanonRepSitefinity\CanonRepSitefinity\CanonV2\SitefinityWebApp.csproj (3,3)". This is most likely a build authoring error. This subsequent import will be ignored. 
D:\a\CanonRepSitefinity\CanonRepSitefinity\CanonV2\SitefinityWebApp.csproj(2085,4): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.
    3 Warning(s)
    1 Error(s)

Time Elapsed 00:00:04.66
SonarScanner for MSBuild 5.9.2
Using the .NET Core version of the Scanner for MSBuild
Post-processing started.
16:03:03.912  The SonarScanner for MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
Possible causes:
16:03:03.912  Generation of the sonar-properties file failed. Unable to complete the analysis.
  1. The project has not been built - the project must be built in between the begin and end steps
  2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
  3. The begin, build and end steps have not all been launched from the same folder
  4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
16:03:03.916  Post-processing failed. Exit code: 1
Error: Process completed with exit code 1.

Any idea ?

Hello @ronnyaloymark

If you remove the SonarQube analysis from the picture entirely, does the build succeed?

All the best,
Čaba

Hello Caba_Sagi
Thank you for reply me
actually no, the build it doesn’t work.
I belive it is because, the github actions is reading the .csproj and this file contains the reference WebApplication.targets, if I remove it, the actions throw other errors.

Do you know other way to do scan in .net framework project without using dotnet?

regards

Hello @ronnyaloymark

My guess is that your build is failing because you don’t have the proper build tools installed to build the web project.

Regarding the analysis, you have to build the project successfully in order for our analyzers to run.

All the best,
Čaba