Why Code Analysis is not working on TFS 2012 build? - tfs

As suggested in one of the related questions that you need to install VS 2012 on the TFS 2012 build server to run Code Analysis as a part of build process.
Due to some reason it is still not working nor giving any error.
Build settings for Code Analysis is set to Always but still it does not run.
However, I have open the same project on the TFS build server in VS 2012 and try to run the Code Analysis and it ran successfully.
I need to get it working.
Can anyone please suggest if I am missing anything here?

You project configuration will need a Code Analysis Ruleset to run against.
You can set this per configuration in your Project Options:

Related

TFS 2015 - Build failed due to exception in the test assemblies

I am trying to run a newly created Build in TFS but i am getting an error as shown in the screenshot below :
Build Configuration
I tried to debug the Unit Test project on my machine and even on the TFS server, it worked fine. So i am not able to understand if there is any configuration missing or issue in the test assemblies code?
Update
Since VS is installed after the build agent configured. Then reregister the build agent with TFS, since the system capabilities are only discovered when the agent is first configured -- any changes made after that are not captured.
First you could also Enable Verbose Debug Mode for TFS Build vNext by add system.debug=true to get more detail log info for trobuleshooting.
According to your build log and configuration, the error occurs after code coverage warning.
Try to uncheck the code coverage option and trigger the build again.
As a prerequisite to using Code Coverage, the first thing to do is to install Visual Studio Enterprise version on the build agent.
I had installed Build Agent before installing Visual Studio. Re-configuring the Build Agent resolved the issue.

Nunit3TestAdapter and TFS Build vNext: Getting a warning: Dependent Assembly nunit.framework not found within VS Test step

I've been scouring various Nunit articles for the past several days trying to figure out the issue with why my Nunit tests are not running.
I am using TFS 2015 Build vNext engine and the Visual Studio Test step to execute my Nunit test cases. The VS 2015 solution used for generating the Nunit test dlls contains the several .net projects and 2 Nunit test projects. Nunit3.0 and Nunit3.0 Test Nuget packages are being used to create and execute the tests. Here is the nuget configuration and nunit.framework reference in my Visual Studio 2015 solution. The test cases run fine in the Visual Studio IDE and compile without error when the solution is build in vNext.
When the VS Test step executes in Build vNext, I get the following warning:
Warning: Dependent Assembly nunit.framework of E:\TFSBuild_Directory\14\s\EBS\B_WebEnable\ABC.Data\ABC.Data.Core.Nunit.Tests\obj\UnitTesting\ABC.Data.Core.Nunit.Tests.dll not found. Can be ignored if not a NUnit project.
The VS Test step is configured:
VS Test Step Configuration
I have confirmed on the build server that the nuget packages are getting restored to the build server and the Nunit.framework.dll appear to be in the expected file path as compared to my local path.
Any ideas as to what could be causing this issue? Any input is appreciated!
I have restored Nunit and Nunit3TestAdapter from Nuget to have a test on my side, but couldn't reproduce your issue. I'd like to share my steps here for your reference:
Restore Nunit and Nunit3TestAdapter from Nuget in VS for the test project (as your first screenshot), and check in the packages.config file.
In "Visual Studio Test" task, specify $(Build.SourcesDirectory)\packages in "Path to Custom Test Adaptors". As if there is a packages folder in the sources directory, it is automatically searched for testadapters (It seems you have a long path, you may need to check it).
I use the default VS template:
No error or warning occurred during this process. You can compare your steps with mine and correct yours. Hope this helps you.
Ok - after stepping away from the issue and coming back to it with fresh eyes, I found the issue causing the nunit.framework.dll issue.
After going step by step through the build definition, I forgot that I had an MSBuild parameter in the build step that was copying the compiled output to another location /p:OutDir=$(build.stagingDirectory)\ABC. Once I changed the test step to point to the new location, everything worked fine. Thanks everyone for the feedback!

TFS 2013 - No Code Coverage Results

I have a TFS 2013 environment setup and I am trying to get TFSBuild to gather my code coverage results after a build.
The tests are running fine, but no matter what I try, I get a message saying "No Code Coverage Results".
I have read about a "Code Coverage Analysis Service", but that is not installed on my servers at all and I can't seem to find it anywhere.
I have gone through the process of the builds to make sure I have the "Automated Tests --> Test Source --> Run settings --> Type of run settings" set to CodeCoverageEnabled, but no matter what else I try, I can't get the results to get published to the Analysis services database so I can run the Code Coverage Reports.
I have tried a run settings file, but with no luck, so I have taken that out of the equation.
Any help would be greatly appreciated!
I just figured out what the problem was that my Code Coverage weren't been calculated on the buildserver. I figured this out with the helpdesk of Microsoft and it is a small UI bug.
Steps to reproduce: Create a new build definition.
Go to the process tab of the build definition and select the solution file to build.
Now expand the "Automated tests" section and expand the "Test Source".
Expand the "Run settings" and change the "Type of run settings" from "Default" to "CodeCoverageEnabled".
Save the builddefinition and run your build.
Examine build results and notice no code coverage is calculated.
To fix this issue use the other ui of the build definition.
Select the "Automated tests" node.
Now in that row on the right you will see a button with "...". Hit it and a dialog will be opened.
Hit "Edit" to edit your test source. You will see that Code coverage is enabled. If not select it.
Hit Ok and Ok again to close the two dialogs.
Now save the build definition and run your build again.
Now the code coverage does get calculated!!! The microsoft helpdesk has submitted a bug to the development team and it will be fixed I guess the next release. Small bug but it cost me more then two days to find the bug!
Do you have a Premium or ultimate visual studio installed on your build machine? Either of those is required to get code coverage results back to TFS
I think the "other window" is referring to right-clicking on the Solution's "Local.testsettings" file (or other [ ].testsettings files), selecting "Open" and navigating through the various setups. When you set the "Test Run location" radio button to "Run tests using local computer or a test controller", there is a setting under "Data and Diagnostics" for "Code Coverage (Visual Studio 2010)".
I am using local build server with Visual Studio online with a .runsettings file and I had exactly the same issue.
None of the trickery above helped, so I tested the build script on the hosted build controller and it worked fine, so I decided the problem must be the build server itself.
I changed the Build Service account from "Network Service" to a regular windows user account in the TFS Configuration Tool and now code coverage is collected. Note that this user will need access to the TFS build directories.
The above workarounds didn't work from me (VS2015 update5 & TFS2013 Update 3).
In my case, Visual Studio was not installed on the build server which is a requirement it seems for code coverage results to be returned.
From MSDN
Microsoft Visual Studio is required to be installed on the build server for the following scenarios:
To build any CPP test project, you must install Visual Studio Professional or later.
To run unit tests, or coded UI tests, you must install Visual Studio Professional or later.
To use data and diagnostic data adapters:
- Code coverage: Visual Studio Premium or later.
- Test impact: Visual Studio Ultimate.
- IntelliTrace: Visual Studio Ultimate.
To build any modern style apps on a build machine: Visual Studio Ultimate or Visual Studio Express for Windows 8 (Operating system on build server must be Windows 8).
To compile and run tests for a project with a faked assembly: Visual Studio Ultimate.

WiX build failing in TFS but working locally

We're using TFS Server 2010 for continuous integration, and also using WiX 3.7 for building. I'm having a problem with the build failing in TFS with the following error:
Unresolved reference to symbol 'Directory:DocumentationDirectory' in section 'Fragment:SharedFragment'.
Now the build works fine on my local machine, but fails in TFS. There is a DocumentationDirectory element in the script so I have no idea why TFS is failing. I've asked around the office and no one can help so I'm posting on StackOverflow.
Any ideas? Help greatly appreciated!
Mark
I have now found the cause of the problem: programmer stupidiy! I had another project in VS that was unloaded but being built by the TFS Server.

MSBuild or TFSBuild Conditional for One Project?

I have a long-time-to-build (setup) project in a Visual Studio 2010 Solution. It is set not to build in the Solution configuration. That way, when a developer builds locally they are not burdened with waiting for the setup to compile in Visual Studio.
However, I am looking for a way to change the configuration in tfsbuild or msbuild files so whenever things are built on the server, the setup project is always built, regardless of what the setting might be when a developer checks in their solution. TFS 2008 is the source control system but just a plain Server 2008 (with devenv fully installed) is the build server.
All clues appreciated.
Thanks.
I would suggest creating a new configuration in your solution, named e.g. Release_Setup, that way you have seperate configurations for developer and setup build (note that developers can choose that config and build everything locally if they so choose, which is quite nice when all Build agents are busy and you want to check that everything's fine).
In Solution Properties->Configuration Properties->Configuration you can even tell it to build the normal Release Configuration and still choose which projects to build and which to exclude.
Hope this helps. I haven't actually tested this, so please try it and comment back if there are any problems or this doesn't solve your specific question.

Resources