I'd like to be able to validate my .csproj
files either as they are added to the solution, or when they are built on our CI build server.
Validation would mean checking, for example:
AssemblyInfo.cs
etc).Another useful feature would be the ability to ignore certain projects, or better still, to be able to define project groupings, with each group having its own validation rules.
This seems to me to be a problem that many others must have, however I have not yet found any tool which could help simplify or automate this process. I'd imagine it to be something like StyleCop or FxCop perhaps.
Does such a tool exist or must I create my own custom build step?
(I am also using ReSharper, so would consider plugins, although this might make validation on the build server more difficult.)
AFAIK there's no tool to achieve this. This is the reason why a collague of mine coded an custom tool to validate .csproj
and .vbproj
files with custom rule validators.
There are some classes to check the project files which might get handy for you like Microsoft.Build.Evaluation.Project
(Assembly Microsoft.Build
), for example. But it gets quite dirty when you're trying to parse solution files. I highly recommend having a look at this question on StackOverflow.
The inhouse validation tool I'm talking about simply checks for defined rules (like the ToolsVersion
, TargetFrameworkVersion
, TargetCPU
, ...) and plots the corresponding output in a format so that the build server can parse the messages and stop a build if an important rule was broken.
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With