asp.net - In a referenced C# library, is there a way to know whether the parent project is Debug or Release? -
i have utility library doing common things in c#.
i want return array of assets in json file in project root, results different depending on whether parent project debug or release.
for example:
{projectroot}\assets.json
{ "debug": { "css": [ "/public/vendor/bootstrap/3.3.5/css/bootstrap.min.css" ], "js": [ "/public/vendor/bootstrap/3.3.5/js/bootstrap.min.js", ] }, "release": { "css": [ "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" ], "js": [ "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js", ] } }
then use checking debug or release , returning proper list viewbag.
i manually in couple projects , i'm start another. add utility project. however, setting #if debug
in library return correct files library build, not parent project.
is there way whether parent project build debug or release without preprocessor wrap?
i set viewbag.assets = mylib.assets
simplicity, rather checking debug or release in parent project , wrapping viewbag setting.
is possible @ all?
my quick , dirty solution
putting property in custom dll this:
public bool isdebug { { #if debug return true; #else return false; #endif } }
it's possible 3-party-ddls be careful. dave black mentions in blog:
first, need define meant "debug" vs. "release"...
object[] attribs = reflectedassembly.getcustomattributes(typeof(debuggableattribute), false); // if 'debuggableattribute' not found optimized build if (attribs.length > 0) { // because 'debuggableattribute' found doesn't mean // it's debug build; have check jit optimization flag // i.e. have "generate pdb" checked have jit optimization enabled debuggableattribute debuggableattribute = attribs[0] debuggableattribute; if (debuggableattribute != null) { hasdebuggableattribute = true; isjitoptimized = !debuggableattribute.isjitoptimizerdisabled; buildtype = debuggableattribute.isjitoptimizerdisabled ? "debug" : "release"; // check debug output "full" or "pdb-only" debugoutput = (debuggableattribute.debuggingflags & debuggableattribute.debuggingmodes.default) != debuggableattribute.debuggingmodes.none ? "full" : "pdb-only"; } } else { isjitoptimized = true; buildtype = "release"; }
also question asked here:
Comments
Post a Comment