Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save rezanid/dfce9bcfb047c50583f5b58bd2a665d1 to your computer and use it in GitHub Desktop.

Select an option

Save rezanid/dfce9bcfb047c50583f5b58bd2a665d1 to your computer and use it in GitHub Desktop.
How to get a project property in a Visual Studio Custom Tool aka Single File Generator
public class ACustomCodeGenerator : BaseCodeGeneratorWithSite
{
private string? GetProjectProperty(string propertyName)
{
ThreadHelper.ThrowIfNotOnUIThread();
return GetService(typeof(IVsHierarchy)) is IVsHierarchy hierarchy ? hierarchy.GetProjectProperty(propertyName) : null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment