Got an annoying problem here. I\'ve got an NHibernate/Forms application I\'m working through SVN. I made some of my own controls, but when I drag and drop those (or view som
I'm way late, and I have no idea if this works in VS2008, but for VS2015, the simplest thing I could think to do was create a t4 template. Here's the contents:
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ output extension=".generated.cs" #>
namespace MyNamespace
{
public static class BuildVariables
{
public static readonly string SolutionDir = <#= QuotedString(Host.ResolveAssemblyReference(@"$(SolutionDir)")) #>;
}
}
<#+
public string QuotedString(string value)
{
if (value == null)
{
return "null";
}
return "@\"" + value.Replace("\"", "\"\"") + "\"";
}
#>
This generates a class that's has exactly what's needed. The two warnings I have for this are to be sure to ignore it from version control, and watch out if you copy your solution somewhere else. Unfortunately, building t4 templates as part of an automated build process is still an complex problem in 2018.