File does not exist in SonarQube analysis - tfs

When analyzing C# project with TFS 2015 vNext build, I get the following error:
The folder
'D:\Builds_Agent1_work\4\s\System\IPS\Files\Logo\MasterDesigns\Logo_11_Seal_of_Pinellas_County'
does not exist for
'DEV_ScriptAdvisorPBM_SonarQube:DEV_ScriptAdvisorPBM_SonarQube:9C5E1BB5-E446-45C8-9CE6-5F9896D0D063'
(base directory = D:\Builds_Agent1_work\4\s\System\IPS)
I think it's because there is a file called "Logo_11_Seal_of_Pinellas_County,_Florida.png" but SonarQube thinks it's "Logo_11_Seal_of_Pinellas_County".
I tried /d:sonar.exclusions=**\MasterDesigns\* to ignore the entire directory where "Logo_11_Seal_of_Pinellas_County,_Florida.png" is located but still same error.
Any suggestions to fix this issue? Thx.
SonarQube 6.5 C# plugin.

This bug is tracked by SONARMSBRU-199 which was fixed in the Scanner for MSBuild v4.1.
The bug report as mentions a workaround for excluding a single file.
FYI support for MSBuild 12 was dropped in the Scanner for MSBuild v4, so if you upgrade the version you will need to make sure you are using a compatible version of MSBuild.

Related

Nuget Installer task fails in tfs 2017 builds

We are using Nuget Installer step that restores the missing nuget packages in TFS build, this step fails with the following error:
E:\Builds\_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.29\node_modules\nuget-task-common\NuGet\3.3.0\NuGet.exe restore -NonInteractive E:\Builds\test.sln
MSBuild auto-detection: using msbuild version '3.5' from 'C:\Windows\Microsoft.NET\Framework\v3.5'.
Error parsing solution file at E:\Builds\test.sln: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
Error: E:\Builds\Agent2017Update1_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.29\node_modules\nuget-task-common\NuGet\3.3.0\NuGet.exe failed with return code: 1
Packages failed to install
The error message seems to be confusing as the file specified is present on build agent.
TFS build agent version:2.112.0
TFS version: TFS 2017 update 1
In the Advanced options change the version to 3.5 for NuGet. I've been having weird issues the last 2 weeks where 3.3 would do similar to what you are experiencing and switching to 3.5 works as expected.
Hope this works for you as well =D
This seems to be due to the fact that the msbuild.exe in your path (your build agent) is version 3.5. MSBuild 3.5 does not have two .dll's that nuget are attempting to load dynamically (Microsoft.Build.dll and Microsoft.Build.Framework.dll).
A solution to fix this issue, please make sure NuGet.exe uses MSBuild
4.0 or higher. This can be done by making sure MSBuild 4.0 or higher is the first to resolve in your path or by passing the -msbuildversion
option. For example, use MSBuild 14.0 (which shipped with Visual
Studio 2015).
nuget.exe pack MyProj.csproj -msbuildversion 14.0
More details please refer this similar issue nuget pack fails when MSBuild version resolved to MSBuild 3.5

No ProjectInfo.xml files were found .TFS build with sonar end task

I am trying to configure my visual studio project to send some analysis data to SonarQube server using TFS 2015 build (vnext)
I get this error in the Sonar end task.
##[error]No ProjectInfo.xml files were found. Possible causes:
##[error]1. The project has not been built - the end step was called right after the begin step, without a build step in between
An unsupported version of MSBuild has been used to build the project. Currently MSBuild 12.0 upwards are supported
We use MSBuild 14.0 in the server.
The SonarQube Scanner for MSBuild requires your project to be built
with MSBuild 14.0. We recommend installing Visual Studio 2015 on the
analysis machine in order to benefit from the integration and features
provided with the Visual Studio ecosystem (VSTest, MSTest unit tests,
etc.).
Suggest you to also install VS2015 on your build server, and since you are using MSbuild 14.0, double check if you are using the old task with deprecated in front which used for MSbuild 12.0. SonarQube Scanner for MSBuild released with static analysis which could executed during the build on MSbuild 14.0.
The support of MSBuild 12 by the SonarQube Scanner for MSBuild is
deprecated and will be removed in a future release.
Source: Compatibility with Visual Studio and MSBuild
Please download and use the latest version of the SonarQube Scanner for MSBuild in marketplace and try again. The recent documentation is available from Analyzing with SonarQube Extension for VSTS/TFS, you could also take a look at this tutorial.

TFS 2015 build SGEN error: 'assembly with incorrect format'

We are upgrading our TFS build system from 2012 to 2015, and are recreating our build machine. We setup the build service, installed necessary dependencies etc. The (legacy) XAML builds are working fine except for the following SGEN error:
SGEN: An attempt was made to load an assembly with an incorrect format: (location of compiled project .dll)
After much Googling and and reading a number of stack overflow articles, I am still at a loss. I referred to multiple pages including:
- SGEN: An attempt was made to load an assembly with an incorrect format
I have tried
Installing Windows SDK 8.1 (and 8.0), 6.1, SDK for Win Server 2008 .net 3.5
Installing .Net 3.5 to 4.6.1
Installing Visual Studio 2010, 2012, 2015
Changing the TFS Build XMAL template file setting MSBuildPlatform to x86 (Microsoft.TeamFoundation.Build.Workflow.Activities.ToolPlatform.x86)
Verified the Generate serialization stratgy setting is set to auto for all projects
Changed the Build definition MSBuildPlatform and 'configuration to build' settings to x86, but this generated multiple (unrelated) errors. Ultimately the compiled projects needs to run as x64.
Also
There is no sgen.exe in the C:/Program Files/.... although there are multiple in C:\Program Files (x86). I cannot confirm that there is an x64 version on the system at all, nor can I find where to install one.
Setting the build 'configuration to build' option to x86 is not an option: this needs to be compiled as x64
We are building a very large code base that is owned by a different team, so changing the .SLN or .csproj files is not really a good solution unless absolutely necessary.
The target platforms in the solution and project files were not correct. I believe in the process of resolving other issues, I had modified the project and solution files platform targets.
Since this upgrade was a trial run, we were able to run the upgrade again, which in effect rolled the code back to the last pre-upgrade set of code.

Error: The imported project "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Default.props" was not found

I have migrated a VS2008 solution to VS2013. My solution contains VC++ projets.
I have set the tools platform to v120_xp for each project
My solution compile on my computer and compile on my builds server in VS2013
My builds server is a Windows2008 R2 with VS2008, VS2010 and VS2013 and a build controler of TeamFoundationServer 2010.
When i launch the build with the build controller, the build fails with :
The imported project "C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Default.props" was
not found. Confirm that the path in the declaration is
correct, and that the file exists on disk.
In the V110 directory this file doesn't exist but it exist in the V120 directory.
I have checked the registry :
HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersion\12.0
the VCTargetPath are corrects
Have you an idea to help me?
I have edited the registry key
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\12.0\11.0
and
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\12.0\11.0
to use the V120 directory
Now my server build the solution, but i don't understand why MSBuild use the key
ToolsVersions\12.0\11.0 and not the key ToolsVersions\12.0\12.0
Parhaps it's due to the v120_xp platform toolset
The true answer is that MSBuild subtracts 1 from the .sln Visual Studio Version. Since you do not have VS 2012 install or you have not installed it, the v11.0 folder is not found. It is all explained by Sayed Ibrahim Hashimi:
http://sedodream.com/PermaLink%2cguid%2ca5894bad-f2a1-441a-a5b2-74f16c6cf8aa.aspx
I came across the same problem in 2015 though, with Windows 10 and Visual Studio 2015 RC (fresh install)
To correct the issue I tried several solutions based on my research ie installing "VS Windows SDK" which didn't do anything different to resolve my problem, I then on another recommendation installed GitHub in order to download MSBuild which is now excluded from VS, I ultimately downloaded and installed "VS Tools for Windows 10" this didn't give me the same error in the end, without having to change registry keys
Installing VS 2012 on your build server should create the necessary targets files for you.
I was able to get past this by changing $(VCTargetsPath) to $(VCTargetsPath12) in the project file.
This feels like a temporary workaround rather than a permanent solution, since once we move to the next version of Visual Studio we'll have to find all the references to $(VCTargetsPath12) and replace with the new target path.

TFS does not build projects correctly

HI
I am trying to build my solution using TFS but it seems to skips the projects which have dependencies.
e.g Proj B depends on Proj A , then it builds only Proj A and not Proj B.
Also if i try to build the projects individually instead of the solution then it does not create the release folder. It says that the output path is not found.
Any help is much appreciated
thanks
Is the SLN file in question converted from an older version of Visual Studio?
I've found that sometimes, like when you upgrade from a VS2003 SLN file to a VS2008 SLN file, it fails in MSBuild (which is what TFS is doing essentially).
Try making a new SLN file in VS2008 (or whatever version you're using) with the same project and see if that fixes it...
If you right-click the solution, one option you'll have is dependencies. Make sure that the projects are correctly setup there, even though they may reference each other the dependencies on the solution itself may not be complete or accurate...and this is what MSBuild uses.
Have a look in the configuration manager and make sure that the build you are running has those projects selected to build.
It may be you are running the Debug configuration for your local build and then running Release on the TFS server and it's not configured the same.

Resources