Skip to content

Commit

Permalink
Fix the NuPgk verification
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredpar committed Feb 26, 2019
1 parent f92f938 commit 5a0fa1a
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 42 deletions.
Expand Up @@ -37,6 +37,7 @@
<_File Include="@(CoreClrCompilerBinArtifact)" TargetDir="tools\bincore"/>
<_File Include="@(CoreClrCompilerBinRuntimesArtifact)" TargetDir="tools\bincore\runtimes"/>

<_File Include="$(MSBuildProjectDirectory)\build\**\*.*" TargetDir="build" />
<TfmSpecificPackageFile Include="@(_File)" PackagePath="%(_File.TargetDir)\%(_File.RecursiveDir)%(_File.FileName)%(_File.Extension)"/>
</ItemGroup>
</Target>
Expand Down
Expand Up @@ -8,8 +8,6 @@

<Target Name="InitializeCoreClrCompilerArtifacts">
<ItemGroup>
<CoreClrCompilerBuildArtifact Include="$(MSBuildProjectDirectory)\build\**" />

<CoreClrCompilerToolsArtifact Include="$(ArtifactsBinDir)Microsoft.Build.Tasks.CodeAnalysis\$(Configuration)\netcoreapp2.1\publish\*.targets" />
<CoreClrCompilerToolsArtifact Include="$(ArtifactsBinDir)Microsoft.Build.Tasks.CodeAnalysis\$(Configuration)\netcoreapp2.1\publish\Microsoft.Build.Tasks.CodeAnalysis.dll" />
<CoreClrCompilerToolsArtifact Include="$(ArtifactsBinDir)Microsoft.Build.Tasks.CodeAnalysis\$(Configuration)\netcoreapp2.1\publish\**\Microsoft.Build.Tasks.CodeAnalysis.resources.dll" />
Expand Down
Expand Up @@ -47,8 +47,7 @@
<_File Include="@(CoreClrCompilerBinRuntimesArtifact)" TargetDir="tasks/netcoreapp2.1/bincore/runtimes"/>

<_File Include="$(MSBuildProjectDirectory)\build\**\*.*" Condition="'$(TargetFramework)' == 'net472'" TargetDir="build" />
<_File Include="$(MSBuildProjectDirectory)\build\**\*.*" Condition="'$(TargetFramework)' == 'net472'" TargetDir="buildMultiTargeting" />
<!-- build multitargeting directory -->
<_File Include="$(MSBuildProjectDirectory)\buildMultiTargeting\**\*.*" Condition="'$(TargetFramework)' == 'net472'" TargetDir="buildMultiTargeting" />

<TfmSpecificPackageFile Include="@(_File)" PackagePath="%(_File.TargetDir)/%(_File.RecursiveDir)%(_File.FileName)%(_File.Extension)" />
</ItemGroup>
Expand Down
79 changes: 41 additions & 38 deletions src/Tools/BuildBoss/CompilerNuGetCheckerUtil.cs
Expand Up @@ -73,7 +73,7 @@ public bool Check(TextWriter textWriter)
var allGood = true;
allGood &= CheckDesktop(textWriter, filter(isDesktop: true));
allGood &= CheckCoreClr(textWriter, filter(isDesktop: false));
allGood &= CheckCombined(textWriter, packageAssets.Select(x => x.FileRelativeName));
allGood &= CheckCombined(textWriter, packageAssets);
return allGood;

IEnumerable<string> filter(bool isDesktop) => packageAssets.Where(x => x.IsDesktop == isDesktop).Select(x => x.FileRelativeName);
Expand All @@ -83,7 +83,6 @@ public bool Check(TextWriter textWriter)
textWriter.WriteLine($"Error verifying: {ex.Message}");
return false;
}

}

/// <summary>
Expand Down Expand Up @@ -116,13 +115,6 @@ private bool CheckDesktop(TextWriter textWriter, IEnumerable<string> assetRelati
/// </summary>
private bool CheckCoreClr(TextWriter textWriter, IEnumerable<string> assetRelativeNames)
{
// The native DLLs ship inside the runtime specific directories but build deploys it at the
// root as well. That copy is unnecessary.
assetRelativeNames = FilterRelativeFileNames(
assetRelativeNames,
"Microsoft.DiaSymReader.Native.amd64.dll",
"Microsoft.DiaSymReader.Native.x86.dll").ToList();

return VerifyNuPackage(
textWriter,
FindNuGetPackage(Path.Combine(ArtifactsDirectory, "packages", Configuration, "Shipping"), "Microsoft.NETCore.Compilers"),
Expand All @@ -133,13 +125,23 @@ private bool CheckCoreClr(TextWriter textWriter, IEnumerable<string> assetRelati
/// <summary>
/// Verify the contents of our combinde toolset compiler packages are correct.
/// </summary>
private bool CheckCombined(TextWriter textWriter, IEnumerable<string> assetRelativeNames)
private bool CheckCombined(TextWriter textWriter, IEnumerable<PackageAsset> packageAssets)
{
var list = new List<string>();
foreach (var asset in packageAssets)
{
var folder = asset.IsDesktop
? @"net472"
: @"netcoreapp2.1";
var fileRelativeName = Path.Combine(folder, asset.FileRelativeName);
list.Add(fileRelativeName);
}

return VerifyNuPackage(
textWriter,
FindNuGetPackage(Path.Combine(ArtifactsDirectory, "packages", Configuration, "Shipping"), "Microsoft.Net.Compilers.Toolset"),
@"tools",
assetRelativeNames);
@"tasks",
list);
}

private bool GetPackageAssets(TextWriter textWriter, List<PackageAsset> packageAssets)
Expand All @@ -165,6 +167,14 @@ private bool GetPackageAssets(TextWriter textWriter, List<PackageAsset> packageA
$@"csc\{Configuration}\netcoreapp2.1\publish",
$@"vbc\{Configuration}\netcoreapp2.1\publish",
$@"VBCSCompiler\{Configuration}\netcoreapp2.1\publish");

// The native DLLs ship inside the runtime specific directories but build deploys it at the
// root as well. That copy is unnecessary.
coreClrAssets.RemoveAll(asset =>
PathComparer.Equals("Microsoft.DiaSymReader.Native.amd64.dll", asset.FileRelativeName) ||
PathComparer.Equals("Microsoft.DiaSymReader.Native.x86.dll", asset.FileRelativeName));

// Move all of the assets into bincore as that is where the non-MSBuild task assets will go
coreClrAssets = coreClrAssets.Select(x => x.WithFileRelativeName(Path.Combine("bincore", x.FileRelativeName))).ToList();

allGood &= GetPackageAssetsCore(
Expand All @@ -189,9 +199,9 @@ private bool GetPackageAssetsCore(TextWriter textWriter, bool isDesktop, List<Pa

IEnumerable<string> enumerateAssets(string directory, SearchOption searchOption = SearchOption.TopDirectoryOnly)
{
var files = Directory.EnumerateFiles(directory, "*.dll", searchOption);
files = files.Concat(Directory.EnumerateFiles(directory, "*.targets", searchOption));
return files;
return Directory
.EnumerateFiles(directory, "*.*", searchOption)
.Where(IsTrackedAsset);
}

// This will record all of the assets files in a directory. The name of the assets and the checksum of the contents will
Expand Down Expand Up @@ -269,27 +279,6 @@ IEnumerable<string> enumerateFiles()
return allGood;
}

private IEnumerable<string> FilterRelativeFileNames(IEnumerable<string> relativeFileNames, params string[] excludeNames)
{
foreach (var relativeFileName in relativeFileNames)
{
var keep = true;
foreach (var excludeName in excludeNames)
{
if (PathComparer.Equals(excludeName, relativeFileName))
{
keep = false;
break;
}
}

if (keep)
{
yield return relativeFileName;
}
}
}

private static bool VerifyNuPackage(
TextWriter textWriter,
string nupkgFilePath,
Expand Down Expand Up @@ -333,8 +322,7 @@ IEnumerable<string> getPartsInFolder()
continue;
}

if ((relativeName.EndsWith(".dll", PathComparison) || relativeName.EndsWith(".targets", PathComparison)) &&
!relativeName.EndsWith(".resources.dll", PathComparison))
if (IsTrackedAsset(relativeName))
{
yield return relativeName;
}
Expand Down Expand Up @@ -403,5 +391,20 @@ private string FindVsix(string fileName)
var file = Directory.EnumerateFiles(directory, fileName).SingleOrDefault();
return file ?? throw new Exception($"Unable to find '{fileName}' in '{directory}'");
}

/// <summary>
/// The set of files that we track as assets in the NuPkg file
/// </summary>
private static bool IsTrackedAsset(string filePath)
{
if (filePath.EndsWith(".dll", PathComparison))
{
return !filePath.EndsWith(".resources.dll");
}

return
filePath.EndsWith(".targets") ||
filePath.EndsWith(".props");
}
}
}

0 comments on commit 5a0fa1a

Please sign in to comment.