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:
parent
d09137f8d5
commit
7d2277d930
2 changed files with 23 additions and 8 deletions
|
@ -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))
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -496,6 +496,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
{
|
||||
CopyExport(outputPath, export);
|
||||
}
|
||||
|
||||
GenerateBindingRedirects(runtimeContext, outputPath, exporter);
|
||||
}
|
||||
else
|
||||
|
@ -508,10 +509,16 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
{
|
||||
var generator = new BindingRedirectGenerator();
|
||||
var config = generator.Generate(exporter.GetAllExports());
|
||||
var path = Path.Combine(outputPath, runtimeContext.ProjectFile.Name + ".exe.config");
|
||||
using (var stream = File.Create(path))
|
||||
|
||||
if (config != null)
|
||||
{
|
||||
config.Save(stream);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue