/// <summary> /// Expands the given macro. /// </summary> /// <param name="macro">The macro to expand.</param> /// <returns> /// The expanded macro. /// </returns> /// <exception cref="BuildException"> /// <para>The macro is not supported.</para> /// <para>-or-</para> /// <para>The macro is not implemented.</para> /// <para>-or-</para> /// <para>The macro cannot be expanded.</para> /// </exception> /// <exception cref="NotImplementedException"> /// <para>Expansion of a given macro is not yet implemented.</para> /// </exception> protected internal override string ExpandMacro(string macro) { // perform case-insensitive expansion of macros switch (macro.ToLower(CultureInfo.InvariantCulture)) { case "targetname": // E.g. WindowsApplication1 return(Path.GetFileNameWithoutExtension(Path.GetFileName( TargetPath))); case "targetpath": // E.g. C:\Doc...\Visual Studio Projects\WindowsApplications1\bin\Debug\WindowsApplications1.exe return(TargetPath); case "targetext": // E.g. .exe return(Path.GetExtension(TargetPath)); case "targetfilename": // E.g. WindowsApplications1.exe return(Path.GetFileName(TargetPath)); case "targetdir": // E.g. C:\Doc...\Visual Studio Projects\WindowsApplications1\bin\Debug return(Path.GetDirectoryName(TargetPath) + (TargetPath.EndsWith( Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture)) ? string.Empty : Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture))); default: return(base.ExpandMacro(macro)); } }
protected virtual string FinalizeTargetPath() { if (TargetPath == null) { throw new CodeFluentCodeDomProducerException(string.Format("invalidProducerImplementation {0}", GetType().FullName)); } return(!TargetPath.EndsWith(CodeDomProducer.FileExtension) ? TargetPath + CodeDomProducer.FileExtension : TargetPath); }