I am trying to set / override some parameters in our TEST TFS installation regarding forced code analysis and complicated settings during the build process (regardless of the installation of the project sin file)
We are currently using our TEST TFS installation:
- Visual Studio 2012 Ultimate On Our Developer Machines And Build A Server
- Install TFS 2012 on one server (application and data tier)
- Install the TFS 2012 service (controller and agent) installed on another server
We can compile examples of .net 4.5 projects (class libraries (DLLs), web applications, etc.), as expected. This is only due to overriding the associated code analysis parameters (hopefully).
Scenario 1. In our examples of applications on our development machines, when choosing project parameters (right-click → properties in the solution explorer), go to the "Code analysis" tab if I turn on "Enable code analysis during assembly" and select a rule set from a dropdown that will be executed as exepcted, so it will generate some warnings. This technical file adds <RunCodeAnalysis>false</RunCodeAnalysis> to the * .csproj file if it is opened in notepad. If the assembly is performed to compile a sample project / solution, then code analysis is performed as expected. I DO NOT want to do this in every project, because the developer can disable it (although I want to have registration policies and / or private / private checks, so it’s all the same).
Scenario 2 - I can turn off the “Enable code analysis on assembly” checkbox and analyze the strength code in our TFSBuild.proj file (we (will) use defaultetemplate.xaml as our default process definition because we will update it with TFS 2008 on our LIVE TFS installation):
<RunCodeAnalysis>Always</RunCodeAnalysis>
This works, and that is how we will strengthen (the lessons that have yet to be studied :-)) Code analysis on our assemblies.
Then a problem arises when setting up other code analysis settings. For example, which default rule set to apply / use or handle CA warnings as errors. Some of these settings can be set either in VS or in all of them by editing * .csproj in notepad. If I edit * .csproj, then these values are used in the assembly as expected (as well as locally on the developer's machine). This is not ideal as I want to do it centrally in TFSBuild.proj without having to edit every project file. I believe that I can use such settings as in the TFSbuild.proj file:
<PropertyGroup> <RunCodeAnalysis>Always</RunCodeAnalysis> <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors> </PropertyGroup>
But they don't seem to work, or am I putting them in the wrong place? How to fix / use them correctly?
FYI I create my solutions in TFSBuild.proj:
<Project DefaultTargets="DesktopBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets" /> <ItemGroup> <SolutionToBuild Include="/some folder/some solution.sln" /> <ConfigurationToBuild Include="Debug|Any CPU"> <FlavorToBuild>Debug</FlavorToBuild> <PlatformToBuild>Any CPU</PlatformToBuild> </ConfigurationToBuild> </ItemGroup> </Project>
On the build server, I found a link to the target file for code analysis in the c: \ Program Files (x86) \ MSBuild \ Microsoft \ VisualStudio \ v11.0 \ CodeAnalysis directory, but I don’t want to change the default behavior to (although it works when I do it). The condition, for example, for CodeAnalysisTreatWarningsAsErrors, should be evaluated as false. Its like my values are not read from TFSBuild.proj, but from the .csproj file.
Any questions feel free to ask and give thanks in advance