未验证 提交 8166286a 编写于 作者: J Jared Parsons 提交者: Jared Parsons

Check the runtimes directory

The runtimes directory needs to be checked in addition to the root
directory. This has the same set of problems with deployed dependencies.
上级 23b01ff6
......@@ -70,7 +70,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.Build" Version="$(MicrosoftBuildFixedVersion)" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="$(MicrosoftBuildTasksCoreFixedVersion)" />
<!-- TODO: condition these on netcore -->
<PackageReference Include="System.IO.Pipes.AccessControl" Version="$(SystemIOPipesAccessControlVersion)" Condition="'$(TargetFramework)' == 'netcoreapp2.0'" />
<PackageReference Include="System.Security.AccessControl" Version="$(SystemSecurityAccessControlVersion)" Condition="'$(TargetFramework)' == 'netcoreapp2.0'" />
</ItemGroup>
......
......@@ -12,15 +12,10 @@
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\System.IO.Compression.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\System.IO.FileSystem.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\System.IO.FileSystem.Primitives.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\System.IO.Pipes.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\System.IO.Pipes.AccessControl.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\System.Security.AccessControl.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\System.Security.Claims.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\System.Security.Cryptography.Algorithms.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\System.Security.Cryptography.Encoding.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\System.Security.Cryptography.Primitives.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\System.Security.Cryptography.X509Certificates.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\System.Security.Principal.Windows.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\System.Text.Encoding.CodePages.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\System.Xml.XmlDocument.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\System.Xml.XPath.dll")]
......
{
"profiles": {
"DevDivInsertionFiles": {
"commandName": "Project",
"commandLineArgs": "e:\\code\\roslyn\\Binaries\\Debug e:\\code\\roslyn e:\\nuget"
}
}
}
\ No newline at end of file
......@@ -56,7 +56,7 @@ public bool Check(TextWriter textWriter)
/// </summary>
private bool CheckDesktop(TextWriter textWriter)
{
var (allGood, dllFileNames) = GetDllFileNames(
var (allGood, dllRelativeNames) = GetDllRelativeNames(
textWriter,
@"Exes\Csc\net46",
@"Exes\Vbc\net46",
......@@ -79,23 +79,23 @@ private bool CheckDesktop(TextWriter textWriter)
"Microsoft.Build.Tasks.Core.dll",
"Microsoft.Build.Utilities.Core.dll",
};
dllFileNames = dllFileNames
dllRelativeNames = dllRelativeNames
.Where(x => !unneededDllFileNames.Contains(x, StringComparer.OrdinalIgnoreCase))
.ToList();
allGood &= VerifySwrFile(textWriter, dllFileNames);
allGood &= VerifySwrFile(textWriter, dllRelativeNames);
allGood &= VerifyNuPackage(
textWriter,
FindNuGetPackage(@"NuGet\PreRelease", "Microsoft.Net.Compilers"),
@"tools",
dllFileNames);
dllRelativeNames);
allGood &= VerifyNuPackage(
textWriter,
FindNuGetPackage(@"DevDivPackages\Roslyn", "VS.Tools.Roslyn"),
string.Empty,
dllFileNames);
dllRelativeNames);
return allGood;
}
......@@ -104,11 +104,11 @@ private bool CheckDesktop(TextWriter textWriter)
/// </summary>
private bool CheckCoreClr(TextWriter textWriter)
{
var (allGood, dllFileNames) = GetDllFileNames(
var (allGood, dllRelativeNames) = GetDllRelativeNames(
textWriter,
@"Exes\Csc\netcoreapp2.0",
@"Exes\Vbc\netcoreapp2.0",
@"Exes\VBCSCompiler\netcoreapp2.0");
@"Exes\Csc\netcoreapp2.0\publish",
@"Exes\Vbc\netcoreapp2.0\publish",
@"Exes\VBCSCompiler\netcoreapp2.0\publish");
if (!allGood)
{
return false;
......@@ -120,7 +120,7 @@ private bool CheckCoreClr(TextWriter textWriter)
"Microsoft.DiaSymReader.Native.amd64.dll",
"Microsoft.DiaSymReader.Native.x86.dll",
};
dllFileNames = dllFileNames
dllRelativeNames = dllRelativeNames
.Where(x => !unneededDllFileNames.Contains(x, StringComparer.OrdinalIgnoreCase))
.ToList();
......@@ -128,13 +128,13 @@ private bool CheckCoreClr(TextWriter textWriter)
textWriter,
FindNuGetPackage(@"NuGet\PreRelease", "Microsoft.NETCore.Compilers"),
@"tools\bincore",
dllFileNames);
dllRelativeNames);
}
/// <summary>
/// Get all of the dependencies in the specified directory set.
/// </summary>
private (bool succeeded, List<string> dllFileNames) GetDllFileNames(TextWriter textWriter, params string[] directoryPaths)
private (bool succeeded, List<string> dllRelativeNames) GetDllRelativeNames(TextWriter textWriter, params string[] directoryPaths)
{
var dllToChecksumMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
var allGood = true;
......@@ -143,23 +143,45 @@ private bool CheckCoreClr(TextWriter textWriter)
// be added to the map
void recordDependencies(MD5 md5, string directory)
{
// Need to consider the files in the immediate directory and those in the runtimes directory. The resource dlls
// are unique and simple to include hence we don't go through the process of verifying them.
IEnumerable<string> enumerateFiles()
{
foreach (var filePath in Directory.EnumerateFiles(directory, "*.dll"))
{
yield return filePath;
}
var runtimeDirectory = Path.Combine(directory, "runtimes");
if (Directory.Exists(runtimeDirectory))
{
foreach (var filePath in Directory.EnumerateFiles(Path.Combine(runtimeDirectory), "*.dll", SearchOption.AllDirectories))
{
yield return filePath;
}
}
}
var normalizedDirectoryName = (directory[directory.Length - 1] == '\\') ? directory : directory + @"\";
string getRelativeName(string filePath) => filePath.Substring(normalizedDirectoryName.Length);
var foundOne = false;
foreach (var dllFilePath in Directory.EnumerateFiles(directory, "*.dll"))
foreach (var dllFilePath in enumerateFiles())
{
foundOne = true;
var dllRelativeName = getRelativeName(dllFilePath);
using (var stream = File.Open(dllFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
var hash = md5.ComputeHash(stream);
var hashString = BitConverter.ToString(hash);
var dllFileName = Path.GetFileName(dllFilePath);
if (dllToChecksumMap.TryGetValue(dllFileName, out string existingHashString))
if (dllToChecksumMap.TryGetValue(dllRelativeName, out string existingHashString))
{
// Make sure that all copies of the DLL have the same contents. The DLLs are being merged into
// a single directory in the resulting NuGet. If the contents are different then our merge is
// invalid.
if (existingHashString != hashString)
{
textWriter.WriteLine($"Dll {dllFileName} exists at two different versions");
textWriter.WriteLine($"Dll {dllRelativeName} exists at two different versions");
textWriter.WriteLine($"\tHash 1: {hashString}");
textWriter.WriteLine($"\tHash 2: {existingHashString}");
allGood = false;
......@@ -167,7 +189,7 @@ void recordDependencies(MD5 md5, string directory)
}
else
{
dllToChecksumMap.Add(dllFileName, hashString);
dllToChecksumMap.Add(dllRelativeName, hashString);
}
}
}
......@@ -218,9 +240,10 @@ IEnumerable<string> getPartsInFolder()
relativeName = relativeName.Substring(1);
}
var comparer = StringComparer.OrdinalIgnoreCase;
if (!comparer.Equals(folderRelativePath, Path.GetDirectoryName(relativeName)) ||
!comparer.Equals(".dll", Path.GetExtension(relativeName)))
var comparison = StringComparison.OrdinalIgnoreCase;
if (!relativeName.StartsWith(folderRelativePath, comparison) ||
!relativeName.EndsWith(".dll", comparison) ||
relativeName.EndsWith(".resources.dll", comparison))
{
continue;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册