Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking Visual Studio projects for consistency

You have a large Visual Studio Solution with dozens of project files in it. How would you verify that all the projects follow certain rules in their property settings, and enforce these rules if a new project is added. For example check that all projects have:

TargetFrameworkVersion = "v4.5"
Platform = "AnyCPU"
WarningLevel = 4
TreatWarningsAsErrors = true
OutputPath = $(SolutionDir)bin
SignAssembly = true
AssemblyName = $(ProjectFolderName)

I know two methods myself that I will add in an answer below, but I was wondering how people go about doing this type of project test. I'm especially interested to learn about available solutions such as libraries or build tasks for this rather than having to have to invent something new or write it from scratch.

like image 919
orad Avatar asked Oct 03 '15 23:10

orad


People also ask

How can I get intellisense in Visual Studio 2019?

Note: We have several Preview features which are off by default and can be enabled through the Tools > Options > IntelliCode page.

How do I see all projects in Visual Studio?

Find in Files (Ctrl+Shift+F): A more robust option, Find in Files is better for searching entire projects or solutions. Unlike Quick Find, Find in Files can list search results in the Find Results window and has additional options to specify which file extensions to search.


1 Answers

*.sln files are plain text and easily parsable, and *.*proj files are xml.

You can add a dummy project with a prebuild step that parses the sln to retrieve all of the project files, validate their settings, print a report, and fail the build if necessary.

Also, you should check this post to ensure the prebuild step is always executed. Essentially, you specify a blank output in the custom build step to force a rebuild.

like image 122
kidmosey Avatar answered Oct 12 '22 09:10

kidmosey