Made some fixes to binding redirects

- Don't generate an empty config file with no redirects.
- Fix swapped publicKeyToken and culture
#462
This commit is contained in:
David Fowler 2015-12-10 01:44:50 -08:00
parent d09137f8d5
commit 7d2277d930
2 changed files with 23 additions and 8 deletions

View file

@ -36,11 +36,19 @@ namespace Microsoft.DotNet.Tools.Compiler
public XDocument Generate(IEnumerable<LibraryExport> dependencies)
{
var redirects = CollectRedirects(dependencies);
if (!redirects.Any())
{
// No redirects required
return null;
}
var document = new XDocument(
new XElement(ConfigurationElementName,
new XElement(RuntimeElementName,
new XElement(AssemblyBindingElementName,
CollectRedirects(dependencies).Select(GetDependentAssembly)
redirects.Select(GetDependentAssembly)
)
)
)
@ -108,8 +116,8 @@ namespace Microsoft.DotNet.Tools.Compiler
var identity = new AssemblyIdentity(
metadataReader.GetString(definition.Name),
definition.Version,
publicKeyToken,
metadataReader.GetString(definition.Culture)
metadataReader.GetString(definition.Culture),
publicKeyToken
);
var references = new List<AssemblyIdentity>(metadataReader.AssemblyReferences.Count);
@ -120,8 +128,8 @@ namespace Microsoft.DotNet.Tools.Compiler
references.Add(new AssemblyIdentity(
metadataReader.GetString(assemblyReference.Name),
assemblyReference.Version,
GetPublicKeyToken(metadataReader.GetBlobBytes(assemblyReference.PublicKeyOrToken)),
metadataReader.GetString(assemblyReference.Culture)
metadataReader.GetString(assemblyReference.Culture),
GetPublicKeyToken(metadataReader.GetBlobBytes(assemblyReference.PublicKeyOrToken))
));
}

View file

@ -496,6 +496,7 @@ namespace Microsoft.DotNet.Tools.Compiler
{
CopyExport(outputPath, export);
}
GenerateBindingRedirects(runtimeContext, outputPath, exporter);
}
else
@ -508,12 +509,18 @@ namespace Microsoft.DotNet.Tools.Compiler
{
var generator = new BindingRedirectGenerator();
var config = generator.Generate(exporter.GetAllExports());
if (config != null)
{
// TODO: Handle existing App.config file transformation
// We have something to generate
var path = Path.Combine(outputPath, runtimeContext.ProjectFile.Name + ".exe.config");
using (var stream = File.Create(path))
{
config.Save(stream);
}
}
}
private static void CopyExport(string outputPath, LibraryExport export)
{