/// <summary> /// Attempts to find the signing key for the specific assembly. /// </summary> /// <param name="inputAssemblyPath"></param> /// <param name="rp"></param> /// <param name="logger"></param> /// <returns></returns> private string GetSigningKeyPath(string inputAssemblyPath, ReaderParameters rp, Core.ILogger logger) { if (KeyFilePath != null) { var path = Path.GetFullPath(KeyFilePath); // only use, if the file exists if (File.Exists(path)) { logger.Info("Using signing key provided by msbuild: '{0}'", path); return(path); } } // fallback as per: https://github.com/Fody/Fody/blob/master/FodyIsolated/StrongNameKeyFinder.cs using (var md = ModuleDefinition.ReadModule(inputAssemblyPath, rp)) { var name = nameof(AssemblyKeyFileAttribute); var keyFileAttr = md.Assembly.CustomAttributes.FirstOrDefault(x => x.AttributeType.Name == name); if (keyFileAttr != null) { var suffix = (string)keyFileAttr.ConstructorArguments.First().Value; var path = Path.Combine(IntermediateDirectory, suffix); logger.Info("Using signing key path from attribute: {0}", path); return(path); } } logger.Warning("No signing key found"); return(null); }