Sonar fxcop plugin with maven fails - fxcop

I try to run mvn sonar:sonar and I get this:
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project YamarinArtifactId: Can not execute Sonar: FxCop execution failed. FxCop execution failed with return code '521'. Check FxCop documentation for more information. -> [Help 1]
Any ideas what to do?

Thanks, "mvn sonar:sonar -X" showed the location of fxcop log file, which then contained an error (missing .dll)

Error 521 is because of the missing DLLs. You have to set the value of
sonar.fxcop.assemblyDependencyDirectories property in the sonar-runner (client).
The value of this should be the Comma-seperated list of path patterns to locate the directories where dependency assemblies can be found. These paths can be absolute or relative, the starting point being the folders where the csproj files are located. Also the special key "$(SolutionDir)" can be used to build a path relative to the root folder of the solution (i.e. where the sln file is located). Check out the note at the bottom of this page for more details.
E.g.: "$(SolutionDir)/**/libs" (and not "$(SolutionDir)/**/libs/*.dll")
eg : I set the value as
sonar.fxcop.assemblyDependencyDirectories=$(SolutionDir)/**/libs,$(SolutionDir)/**/Debug
and the things started working for me. :)

Related

Visual Studio Extension build failing with Error VSSDK1077: Unable to locate the extensions directory. "Value cannot be null

I have configured a TFS(2017) build pipeline to compile a VS extension with debug mode for a specific requirement which require .pdb files.
The build solution task fails for "debug" configuration with below error, however same pipeline works for the release configuration.
I have tried the approach mentioned in the following discussion as well, howewer it doesn't resolve my issue.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/fd220999-5761-475a-bf86-98dff6b35218/unable-to-compile-vsix-project-that-is-a-part-of-my-solution-using-amd64-msbuild-from-vs2015?forum=msbuild
Appreciate if someone can help me to resolve this issue.
Following is the build configuration used for the Build Solution task:
Following build variables are used to configure build parameters.
Build Error message:
packages\Microsoft.VSSDK.BuildTools.15.1.192\tools\VSSDK\Microsoft.VsSDK.targets
(633, 5)
packages\Microsoft.VSSDK.BuildTools.15.1.192\tools\VSSDK\Microsoft.VsSDK.targets(633,5):
Error VSSDK1077: Unable to locate the extensions directory. "Value
cannot be null. Parameter name: path1". Process 'msbuild.exe' exited
with code '1'.
Update your Microsoft.VSSDK.BuildTools NuGet package to latest version 15.9.3032, just in case it is a problem already solved.
Release configurations can also generate PDB files (Project properties, Build tab, Advanced...button, Output > Debugging information). So, if the Release configuration works for you, you can keep using it while also generating a pdb file with full debug information.
The error is happening when, once compiled correctly, the generated VSIX output file is going to be deployed to the folder for extensions of the experimental VS instance, which is a required step to debug the VSIX file. A possible explanation of the different behavior for Debug/Release configurations is that maybe your .csproj specifies <DeployExtension>False</DeployExtension> for the Release configuration. By default, if not set, that property is set to true in the Microsoft.VsSDK.targets file:
<DeployExtension Condition="'$(DeployExtension)' == ''">true</DeployExtension>
Since likely you don't need to deploy the VSIX to the VS experimental instance when building on a build server (because you are not going to debug it), you can set that property to False to skip the deployment. This can be done with a 3rd build configuration (ex: "DebugBuildServer"), for which you specify DeployExtension to False in the .csproj file, or sticking to two build configurations but passing the /p:DeployExtension=false in the MSBuild arguments of the Visual Studio Build task of your build pipeline.

Error while running SonarQube - No ProjectInfo.xml files were found

I am using SonarQube 5.2 for calculating the metrics.
Everything works fine, when I run it using "Developer Command Prompt for VS2013".
But when I run the same commands using normal command prompt "cmd.exe" with or without administrator rights, I am getting the following error
C:\Windows\system32>"C:\sonarqube-5.2\bin\MSBuild.SonarQube.Runner.exe" end
SonarQube Scanner for MSBuild 1.1
Default properties file was found at C:\sonarqube-5.2\bin\SonarQube.Analysis.xml
Loading analysis properties from C:\sonarqube-5.2\bin\SonarQube.Analysis.xml
Post-processing started.
MSBuild SonarQube Runner Post-processor 1.0.2.0
11:39:29.774 sonar.verbose=true was specified - setting the log verbosity to 'Debug'
11:39:29.774 Loading the SonarQube analysis config from C:\Windows\system32\.sonarqube\conf\SonarQubeAnalysisConfig.xml
11:39:29.774 Not running under TeamBuild
11:39:29.774 Analysis base directory: C:\Windows\system32\.sonarqube
Build directory:
Bin directory: C:\Windows\system32\.sonarqube\bin
Config directory: C:\Windows\system32\.sonarqube\conf
Output directory: C:\Windows\system32\.sonarqube\out
Config file: C:\Windows\system32\.sonarqube\out
Generating SonarQube project properties file to C:\Windows\system32\.sonarqube\out\sonar-project.properties
No ProjectInfo.xml files were found. Possible causes: you specified an invalid build configuration or the custom MSBuild analysis targets were not imported.
Writing processing summary to C:\Windows\system32\.sonarqube\out\ProjectInfo.log
Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
11:39:29.79 Creating a summary markdown file...
Post-processing failed. Exit code: 1
Please let me know what could be isssue and how to resolve it.
The following steps are followed by me,
Executed all the commands from one location example - "D:\Test"
Added the following in the PATH environment variable
a. path to MSBUILD's 12.0 folder
The commands executed for analysis of metrics,
a. MSBuild.SonarQube.Runner.exe begin
b. MSBuild abc.csproj /t:Clean;Rebuild /p:VisualStudioVersion=12.0...;
c. MSBuild.SonarQube.Runner.exe end
I got the solution.
I should use the full path to MSBuild instead of putting it in the PATH variable, which causes this issue for SonarQube Analysis.
-->
MSBuild.SonarQube.Runner.exe begin
"%programfiles(x86)%\msbuild\12.0\bin\MSBuild.exe" abc.csproj /t:Clean;Rebuild /p:VisualStudioVersion=12.0...;
MSBuild.SonarQube.Runner.exe end
<--
I think, any command that requires Developer Command Prompt, should also work in the normal command prompt, provided the path to MSBUILD should be in full.
Regards,
Guru
This worked well. :)
Use the below lines code one by one after each exection is completed:
SonarQube.Scanner.MSBuild.exe begin /k:"ProjectKeyName" /n:"ProjectName" /v:"1.0"
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /t:Rebuild
SonarQube.Scanner.MSBuild.exe end
Note:
Please replace the ProjectKeyname and projectName with yours (As per sonar-project.properties file created under your Project Root Folder)
Version used:
sonarqube-5.6.6 (tested in sonarqube-6.4 as well),
sonar-scanner-msbuild-3.0.0.629

Build using TeamCity: Failed to start MSBuild; please specify a nuspec or project file to use

I'm trying to build a website in Teamcity, but the first build step "starting MSBuild" is failing.It seems that the command is trying to install nuget, but it is complaining that there is no nuspec or project file specified.
I have a "nuget.targets" file and the code compiles fine outside of teamcity , so I think it must be a setting I am missing, and not a file I actually need to add but maybe I do need to add a nuspec or project file? Assuming I do, how would I go about doing that?
[Exec] C:\TeamCity\buildAgent\work\61cf1fbc18b86c6f\.nuget\NuGet.targets
(109, 9): Please specify a nuspec or project file to use.
I am completely new to Teamcity (~3hrs); how do I resolve this problem?
If a build fails or behaves differntly in TeamCity than locally, then it is recommended to run the build in the working folder on agent machine under the same user that the agent is running. Find more details here.

TeamCity error MSB3021: Unable to copy file

I have a TeamCity. I have setup build for my web project (csproj) with msbuild,
command line parameter is looks like
/p:Configuration=%env.Configuration% /p:outputpath=bin2
/p:DeployOnBuild=True /p:IsDesktopBuild=false
/p:DeployTarget=MSDeployPublish
/p:MsDeployServiceUrl=httppath
/p:AllowUntrustedCertificate=True /p:MSDeployPublishMethod=WMSVC
/p:UserName=xxx /p:Password=xxx
but build faild all the time with error:
Step 1/1: MSBuild (7s)
pathxxx\MyPortal.csproj.teamcity: Build target: Build (4s)
[pathxxx\MyPortal.csproj.teamcity] _CopyWebApplicationLegacy
[_CopyWebApplicationLegacy] Copy
[Copy] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets(178, 5): error MSB3021: Unable to copy file "Bin\MyPortal.dll" to "bin2\_PublishedWebsites\MyPortal.csproj\Bin\MyPortal.dll". Could not find a part of the path 'Bin\MyPortal.dll'.
[Copy] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets(178, 5): error MSB3021: Unable to copy file "Bin\MyPortal.pdb" to "bin2\_PublishedWebsites\MyPortal.csproj\Bin\MyPortal.pdb". Could not find a part of the path 'Bin\MyPortal.pdb'.
[pathxxx\MyPortal.csproj.teamcity] Project pathxxx\MyPortal.csproj.teamcity failed.
[Step 1/1] Step MSBuild failed
if I removed /p:outputpath=bin2 parameter i see other king of error,
The OutputPath property is not set for project
'MyPortal.csproj.teamcity'. Please check to
make sure that you have specified a valid combination of Configuration
and Platform for this project. Configuration='TestEnv' Platform='Any
CPU'. You may be seeing this message because you are trying to build
a project without a solution file, and have specified a non-default
Configuration or Platform that doesn't exist for this project.
I am using xml transformation and I have make shure that TestEnv is exist in all project inside solution.
What it could be ? and how to fix it ?
Thanks.
have you added a configuration testenv to all your projects? as its missing the OutputPath property.Alternatively you could just add the property to your initial command e.g. /p:OutputPath=..\output .

teamcity building project Failed to start MSBuild.exe. Illegal characters in path

I am trying to build a project within teamcity. It will do the checkout of TFS and the files are locally on the build server. If I manually run the build command on the server it works:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe C:\TeamCity\buildAgent\work\3446a5bd436eea87\Dev\Dev\project\myproj\myproj.csproj /t:build
Within Teamcity I have a Build step of MSBuild:
the build fie path is: Dev\Dev\project\myproj\myproj.csproj"
working directory left blank
mbuild version: microsoft .net framework 4.0
msbuild toolsversion: 4.0
run platform: X86
targets: I have tried build "build" and left blank
command line params left blank
if I create a command line build task and run the above command line it works. I am not sure what differences there are between the command line and msbuild task within teammcity.
EDIT
I have tried a few variations on the working directory:
The output path in project is set to ..\Build\Tools\myproj\
So I have set the working directory in teamcity to: Dev\Dev\project\Build\Tools\myproj\
This didn't help.
Here is the exact output from teamcity:
Starting: C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MsBuildBootstrap.exe /workdir:C:\TeamCity\buildAgent\work\3446a5bd436eea87\Dev\Dev\project\Build\Tools\myproj /msbuildPath:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
in directory: C:\TeamCity\buildAgent\work\3446a5bd436eea87\Dev\Dev\project\Build\Tools\myproj
Failed to start MSBuild.exe. Illegal characters in path.
System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path)
at System.IO.Path.IsPathRooted(String path)
at JetBrains.TeamCity.Utils.FileUtil.MakeFullPath(String path, String workDir) in c:\BuildAgent\work\c2314fd21f15dc97\src\Utils\src\FileUtil.cs:line 48
at JetBrains.BuildServer.MSBuildBootstrap.RunArgs.get_ProjectFile() in c:\BuildAgent\work\c2314fd21f15dc97\src\MSBuildBootstrap\src\RunArgs.cs:line 156
at JetBrains.BuildServer.MSBuildBootstrap.Impl.MSBuildBootstrapFactory.Create(IClientRunArgs args) in c:\BuildAgent\work\c2314fd21f15dc97\src\MSBuildBootstrap.Core\src\Impl\MSBuildBootstrapFact ory.cs:line 29
at JetBrains.BuildServer.MSBuildBootstrap.Program.Run(String[] _args) in c:\BuildAgent\work\c2314fd21f15dc97\src\MSBuildBootstrap\src\Program.cs:line 67
Try editing the build configuration and remove the quotes from the Build file path option.
If you have:
"Dev\Dev\project\myproj\myproj.csproj"
Just let:
Dev\Dev\project\myproj\myproj.csproj
I hope this help.
In TeamCity, when you are using parameters for your path, or a portion of the path, it is easy to paste in a folder and not notice that it has a New Line or Carriage Return on the end (as I found from painful experience). It could show up in TeamCity as the value for a parameter:
\Folder1\NewlyPastedInFolder
\ExistingFolder\BuildScripts
What looks like a word-wrapped value is actually a parameter with a carriage return in the middle. Check it by editing it, and see if you can delete the character to make it into a single-line value.
This questions seems very similar:
What's the illegal character in this string ? I'm getting MSBUILD : error MSB3095
In addition to this question, take a look at:
What is a dll.refresh file in ASP.Net?
On this question, this answer is of interest:
In an ASP.NET project, adding a file-based reference will add a
.refresh file in the Bin folder. When the project is under source
control, this file is then added to source control. *.dll.refresh
files that litter the bin directory. Every time you add an external
reference, you'll find a dll.refresh file right next to it. These
dll.refresh files are an exception to the rule, and they should go
into source control. Its the only way your web project will know where
its references live.
If you don't have this in source control, it could explain the problem you are seeing. It sounds like the error message is potentially misleading and this is related to a reference not being resolved on the build machine.
With regards to why it works from the command line, is it possible that when you are building from TeamCity it is cleaning the output directory before building? If when you run from the command line binaries have already been output from the partially failed build which are referenced as file references, this would succeed.
To identify if this is the case - if you do a completely clean checkout and then run the MSBuild step from the command line, does it still succeed?
I ran into this error message from TeamCity and it turned out that a space in the solution file was causing it (the solution file referenced in the Visual Studio Build Steps had double quotes around it and that didn't seem to help.) Renamed the solution file without the space and that solved the problem.