Month: January 2019

Access app.config from a texttemplate

<#@ template debug=”false” hostspecific=”true” language=”C#” #> <#@ assembly name=”System.Core” #> <#@ assembly name=”System.Configuration” #> <#@ import namespace=”System.Linq” #> <#@ import namespace=”System.Text” #> <#@ import namespace=”System.Collections.Generic” #> <#@ import namespace=”System.Configuration” #> <#@ output extension=”.tt.cs” #> <# var projectPath = Host.ResolveAssemblyReference(“$(ProjectDir)”); var configFile = projectPath + “App.config”; var map = new ExeConfigurationFileMap() { ExeConfigFilename = configFile }; Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);… Read more →