Validate project name programmatically

392 views Asked by At

I am working on a tool that uses the Microsoft.Build namespaces, to programmatically build a C# project, among other things. The projects can be created via Visual Studio or generated using parameter substitution of code template.

I need to validate that the given project is a valid one. I came across this question that has rules for a valid project name, but I believe the list is incomplete.

For example - as per the C# CLS - an identifier cannot be used in a project name, unless it is prefixed with @. Referred here. Another example is, if the input project name is a number, then Visual Studio prefixes it with an underscore.

So, question is - is there a namespace/api/fancy regular expression that I can use to create a new C# project programmatically, outside of Visual Studio, that will apply all such rules that the C# CLS specifies?

0

There are 0 answers