private static string GetProjectDirectoryFromType(Type classToFindProjectDirOf)
{
const string debugEnding = @"\bin\debug";
const string releaseEnding = @"\bin\release";
var pathToManipulate = Environment.CurrentDirectory;
string projectDir = null;
if (pathToManipulate.EndsWith(debugEnding, StringComparison.InvariantCultureIgnoreCase))
projectDir = pathToManipulate.Substring(0, pathToManipulate.Length - debugEnding.Length);
if (pathToManipulate.EndsWith(releaseEnding, StringComparison.InvariantCultureIgnoreCase))
projectDir = pathToManipulate.Substring(0, pathToManipulate.Length - releaseEnding.Length);
if (projectDir == null)
throw new InvalidOperationException($"Expected directory ending in {debugEnding} or {releaseEnding} but got {pathToManipulate}"+
"Please use one of the other forms of the CheckBundles ctor and provide the absolute path to the project.");
return Path.Combine(projectDir.Substring(0, projectDir.LastIndexOf("\\", StringComparison.Ordinal)),
classToFindProjectDirOf.Assembly.GetName().Name);
}