Is there an API for programmatically modifying Project and Solution files (.vbproj, .csproj, .sln)?

We support a large number of .NET Project and Solution files manually; it is ugly tiring and needs to be automated. Files are all XML, so writing a tool for our purposes would not be difficult, but I was wondering if anyone knew of a VS or TFS API object that would allow me to work with these files as objects without creating my own class.

For our purposes, we need to ensure that all projects comply with a number of standards: - basic addressing - custom assembly types - specific properties for each type of assembly - custom "After assembly" actions

I found APIs for working with projects when they are loaded into Visual Studio, and I am weighing the possibility of writing an add-in for our needs, but ideally I would just like to deserialize the object directly from files; make sure it meets the requirements; if necessary, make changes and serialize the object back to the file.

fyi: If you are looking for the same, let me know; I am interested in writing this after work and sharing it with CodePlex. There will be some interceptors for my purposes in TFS, but I would like to create something useful for others as well.

+4
source share
2 answers

Get msbuild.xsd from the local schema cache and use xsd.exe on it.

If you want to add custom assembly task support, use MSBuildSchemaGen to create a custom XSD for your task assemblies.

If xsd.exe output does not make you feel good, use XsdTidy to improve it.

+4
source

Since XML is a tool that can do what you need by invoking XML.NET Classes, etc. and changing what you like.

0
source

Source: https://habr.com/ru/post/1286230/


All Articles