Skip to content

Instantly share code, notes, and snippets.

@jordanrobinson
Last active April 1, 2019 15:46
Show Gist options
  • Save jordanrobinson/0e399dd9c5f8686b9615341e51fcec3d to your computer and use it in GitHub Desktop.
Save jordanrobinson/0e399dd9c5f8686b9615341e51fcec3d to your computer and use it in GitHub Desktop.
Version Helper 1
public static string VersionHash(this HtmlHelper helper)
{
var assembly = typeof(TheCurrentClassYou'reCallingFrom).Assembly;
var attributes = assembly.GetCustomAttributes<AssemblyMetadataAttribute>();
var hash = attributes.FirstOrDefault(a => a.Key == "GitHash")?.Value;
return hash?.Replace("-dirty", string.Empty);
}
public static string SiteVersion(this HtmlHelper helper)
{
return typeof(HTMLExtensions).Assembly.GetName().Version.ToString();
}
<script src="/_scripts/[email protected]()"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment