public string GetBuildEngineKey() { var projectFilePath = buildEnginePropertyExtractor.GetProjectPath(); var xDocument = XDocument.Load(projectFilePath); var weavingTaskName = config.GetType().Assembly.GetName().Name + "." + config.GetType().Name; var weavingTaskNode = xDocument.BuildDescendants(weavingTaskName).First(); var xAttribute = weavingTaskNode.Parent.Attribute("Name"); if (xAttribute == null) { throw new Exception("Target node contains no 'Name' attribute."); } ; var targetNodeName = xAttribute.Value.ToUpperInvariant(); switch (targetNodeName) { case ("AFTERCOMPILE"): { return("IntermediateAssembly"); } case ("AFTERBUILD"): { return("TargetPath"); } } throw new Exception( string.Format( @"Failed to derive TargetPath from target node. WeavingTask is located in '{0}'. Target path can only be derived when WeavingTask is located in 'AfterCompile' or 'AfterBuild'. Please define 'TargetPath' as follows: <WeavingTask ... TargetPath=""PathToYourAssembly"" />", targetNodeName)); }
public void Execute() { if (config.KeyFilePath == null) { var projectFilePath = buildEnginePropertyExtractor.GetProjectPath(); if (!IsSignAssemblyTrue(projectFilePath)) { return; } var assemblyOriginatorKeyFile = GetKeyFile(projectFilePath); if (assemblyOriginatorKeyFile == null) { return; } config.KeyFilePath = Path.Combine(Path.GetDirectoryName(projectFilePath), assemblyOriginatorKeyFile); } StrongNameKeyPair = new StrongNameKeyPair(File.OpenRead(config.KeyFilePath)); }