Remove duplicate paths
This commit is contained in:
parent
e62e5a2bef
commit
282ccd6999
|
|
@ -79,7 +79,6 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
||||||
#else
|
#else
|
||||||
"System.Linq",
|
"System.Linq",
|
||||||
"System.Collections",
|
"System.Collections",
|
||||||
"System.Dynamic",
|
|
||||||
"System.Dynamic.Runtime",
|
"System.Dynamic.Runtime",
|
||||||
"System.Collections.Generic",
|
"System.Collections.Generic",
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -88,6 +87,8 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
||||||
"Microsoft.AspNet.Mvc.Rendering",
|
"Microsoft.AspNet.Mvc.Rendering",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var exports = new List<IDependencyExport>();
|
||||||
|
|
||||||
foreach (var assemblyName in assemblies)
|
foreach (var assemblyName in assemblies)
|
||||||
{
|
{
|
||||||
var export = _exporter.GetDependencyExport(assemblyName, _environment.TargetFramework);
|
var export = _exporter.GetDependencyExport(assemblyName, _environment.TargetFramework);
|
||||||
|
|
@ -97,42 +98,57 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtractReferences(export, references);
|
exports.Add(export);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExtractReferences(exports, references);
|
||||||
|
|
||||||
return references;
|
return references;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExtractReferences(IDependencyExport export, List<MetadataReference> references)
|
private void ExtractReferences(List<IDependencyExport> exports, List<MetadataReference> references)
|
||||||
{
|
{
|
||||||
foreach (var metadataReference in export.MetadataReferences)
|
var paths = new HashSet<string>();
|
||||||
|
|
||||||
|
foreach (var export in exports)
|
||||||
{
|
{
|
||||||
var fileMetadataReference = metadataReference as IMetadataFileReference;
|
foreach (var metadataReference in export.MetadataReferences)
|
||||||
|
|
||||||
if (fileMetadataReference != null)
|
|
||||||
{
|
{
|
||||||
string path = fileMetadataReference.Path;
|
var fileMetadataReference = metadataReference as IMetadataFileReference;
|
||||||
#if NET45
|
|
||||||
references.Add(new MetadataFileReference(path));
|
if (fileMetadataReference != null)
|
||||||
#else
|
|
||||||
// TODO: What about access to the file system? We need to be able to
|
|
||||||
// read files from anywhere on disk, not just under the web root
|
|
||||||
using (var stream = File.OpenRead(path))
|
|
||||||
{
|
{
|
||||||
references.Add(new MetadataImageReference(stream));
|
string path = fileMetadataReference.Path;
|
||||||
|
|
||||||
|
paths.Add(path);
|
||||||
}
|
}
|
||||||
#endif
|
else
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var roslynReference = metadataReference as IRoslynMetadataReference;
|
|
||||||
|
|
||||||
if (roslynReference != null)
|
|
||||||
{
|
{
|
||||||
references.Add(roslynReference.MetadataReference);
|
var roslynReference = metadataReference as IRoslynMetadataReference;
|
||||||
|
|
||||||
|
if (roslynReference != null)
|
||||||
|
{
|
||||||
|
references.Add(roslynReference.MetadataReference);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
references.AddRange(paths.Select(CreateMetadataFileReference));
|
||||||
|
}
|
||||||
|
|
||||||
|
private MetadataReference CreateMetadataFileReference(string path)
|
||||||
|
{
|
||||||
|
#if NET45
|
||||||
|
return new MetadataFileReference(path);
|
||||||
|
#else
|
||||||
|
// TODO: What about access to the file system? We need to be able to
|
||||||
|
// read files from anywhere on disk, not just under the web root
|
||||||
|
using (var stream = File.OpenRead(path))
|
||||||
|
{
|
||||||
|
return new MetadataImageReference(stream);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private CompilationMessage GetCompilationMessage(DiagnosticFormatter formatter, Diagnostic diagnostic)
|
private CompilationMessage GetCompilationMessage(DiagnosticFormatter formatter, Diagnostic diagnostic)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue