Skip to content

Commit

Permalink
Rebuild as many projects as possible (#51427)
Browse files Browse the repository at this point in the history
  • Loading branch information
RikkiGibson authored Feb 26, 2021
1 parent 3b920f1 commit 9438f74
Show file tree
Hide file tree
Showing 25 changed files with 194 additions and 38 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ jobs:
filePath: eng/build.ps1
arguments: -configuration Debug -prepareMachine -ci -restore -binaryLog

- powershell: .\eng\test-rebuild.ps1 -ci
- powershell: .\eng\test-rebuild.ps1 -ci -configuration Release
displayName: Run BuildValidator

- task: PublishBuildArtifacts@1
Expand Down
15 changes: 11 additions & 4 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
<MicrosoftCodeAnalysisTestingVersion>1.0.1-beta1.20623.3</MicrosoftCodeAnalysisTestingVersion>
<CodeStyleAnalyzerVersion>3.8.0</CodeStyleAnalyzerVersion>
<VisualStudioEditorPackagesVersion>16.8.181</VisualStudioEditorPackagesVersion>
<ILToolsPackageVersion>5.0.0-alpha1.19409.1</ILToolsPackageVersion>
<ILAsmPackageVersion>5.0.0-alpha1.19409.1</ILAsmPackageVersion>
<ILDAsmPackageVersion>5.0.0-preview.1.20112.8</ILDAsmPackageVersion>
<MicrosoftVisualStudioLanguageServerProtocolPackagesVersion>16.9.150</MicrosoftVisualStudioLanguageServerProtocolPackagesVersion>
<MicrosoftVisualStudioShellPackagesVersion>16.8.30406.65-pre</MicrosoftVisualStudioShellPackagesVersion>
<!-- The version of Roslyn we build Source Generators against that are built in this
Expand Down Expand Up @@ -245,9 +246,15 @@
<xunitrunnerwpfVersion>1.0.51</xunitrunnerwpfVersion>
<xunitrunnervisualstudioVersion>$(xunitVersion)</xunitrunnervisualstudioVersion>
<xunitextensibilityexecutionVersion>$(xunitVersion)</xunitextensibilityexecutionVersion>
<runtimeWinX64MicrosoftNETCoreILAsmPackageVersion>$(ILToolsPackageVersion)</runtimeWinX64MicrosoftNETCoreILAsmPackageVersion>
<runtimeLinuxX64MicrosoftNETCoreILAsmPackageVersion>$(ILToolsPackageVersion)</runtimeLinuxX64MicrosoftNETCoreILAsmPackageVersion>
<runtimeOSXX64MicrosoftNETCoreILAsmPackageVersion>$(ILToolsPackageVersion)</runtimeOSXX64MicrosoftNETCoreILAsmPackageVersion>

<runtimeWinX64MicrosoftNETCoreILAsmPackageVersion>$(ILAsmPackageVersion)</runtimeWinX64MicrosoftNETCoreILAsmPackageVersion>
<runtimeLinuxX64MicrosoftNETCoreILAsmPackageVersion>$(ILAsmPackageVersion)</runtimeLinuxX64MicrosoftNETCoreILAsmPackageVersion>
<runtimeOSXX64MicrosoftNETCoreILAsmPackageVersion>$(ILAsmPackageVersion)</runtimeOSXX64MicrosoftNETCoreILAsmPackageVersion>

<runtimeWinX64MicrosoftNETCoreILDAsmPackageVersion>$(ILDAsmPackageVersion)</runtimeWinX64MicrosoftNETCoreILDAsmPackageVersion>
<runtimeLinuxX64MicrosoftNETCoreILDAsmPackageVersion>$(ILDAsmPackageVersion)</runtimeLinuxX64MicrosoftNETCoreILDAsmPackageVersion>
<runtimeOSXX64MicrosoftNETCoreILDAsmPackageVersion>$(ILDAsmPackageVersion)</runtimeOSXX64MicrosoftNETCoreILDAsmPackageVersion>

<!--
NOTE: The following dependencies have been identified as particularly problematic to update.
If you bump their versions, you must push your changes to a dev branch in dotnet/roslyn and
Expand Down
File renamed without changes.
31 changes: 31 additions & 0 deletions eng/targets/ILDAsm.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Project>
<!--
This logic is adding the ILDASM executable to the runtime directory of all projects that include
this target file. The build provenance tools need this to decompile IL for debugging purposes.
-->
<ItemGroup>
<Content Include="$(NuGetPackageRoot)\runtime.win-x64.microsoft.netcore.ildasm\$(runtimeWinX64MicrosoftNETCoreILDAsmPackageVersion)\runtimes\**\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<LinkBase>runtimes</LinkBase>
<Visible>false</Visible>
<Pack>false</Pack>
</Content>
<Content Include="$(NuGetPackageRoot)\runtime.linux-x64.microsoft.netcore.ildasm\$(runtimeLinuxX64MicrosoftNETCoreILDAsmPackageVersion)\runtimes\**\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<LinkBase>runtimes</LinkBase>
<Visible>false</Visible>
<Pack>false</Pack>
</Content>
<Content Include="$(NuGetPackageRoot)\runtime.osx-x64.microsoft.netcore.ildasm\$(runtimeOSXX64MicrosoftNETCoreILDAsmPackageVersion)\runtimes\**\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<LinkBase>runtimes</LinkBase>
<Visible>false</Visible>
<Pack>false</Pack>
</Content>

<PackageReference Include="runtime.win-x64.Microsoft.NETCore.ILDAsm" Version="$(runtimeWinX64MicrosoftNETCoreILDAsmPackageVersion)" ExcludeAssets="all" />
<PackageReference Include="runtime.linux-x64.Microsoft.NETCore.ILDAsm" Version="$(runtimeLinuxX64MicrosoftNETCoreILDAsmPackageVersion)" ExcludeAssets="all" />
<PackageReference Include="runtime.osx-x64.Microsoft.NETCore.ILDAsm" Version="$(runtimeOSXX64MicrosoftNETCoreILDAsmPackageVersion)" ExcludeAssets="all" />
</ItemGroup>
</Project>
40 changes: 36 additions & 4 deletions eng/test-rebuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,45 @@ try {

$dotnetInstallDir = (InitializeDotNetCli -install:$true)
$rebuildArgs = ("--verbose" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis/$configuration`"" +
" --assembliesPath $ArtifactsDir/obj/csc/$configuration/netcoreapp3.1" +
" --assembliesPath `"$ArtifactsDir/obj/AnalyzerRunner/$configuration/netcoreapp3.1`"" +
" --assembliesPath `"$ArtifactsDir/obj/AnalyzerRunner/$configuration/net5.0`"" +
" --assembliesPath `"$ArtifactsDir/obj/CodeStyleConfigFileGenerator`"" +
" --assembliesPath `"$ArtifactsDir/obj/csc/$configuration/netcoreapp3.1`"" +
" --assembliesPath `"$ArtifactsDir/obj/CSharpResultProvider.NetFX20`"" +
" --assembliesPath `"$ArtifactsDir/obj/CSharpSyntaxGenerator`"" +
" --assembliesPath `"$ArtifactsDir/obj/csi/$configuration/netcoreapp3.1`"" +
" --assembliesPath `"$ArtifactsDir/obj/IdeCoreBenchmarks/$configuration/netcoreapp3.1`"" +
" --assembliesPath `"$ArtifactsDir/obj/IdeCoreBenchmarks/$configuration/net5.0`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.CodeStyle`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.CodeStyle.Fixes`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.Compiler.Test.Resources`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.CSharp`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.CSharp.CodeStyle`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.CSharp.ExpressionCompiler`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.CSharp.Features`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.CSharp.Workspaces`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.EditorFeatures.Text`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.ExpressionCompiler`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.ExternalAccess.Debugger`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.ExternalAccess.Razor`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.Remote.Razor.ServiceHub`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.Remote.Workspaces`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.ResultProvider`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.Scripting`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.Scripting.TestUtilities`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.TestSourceGenerator`"" +
" --assembliesPath `"$ArtifactsDir/obj/Microsoft.CodeAnalysis.Workspaces`"" +
" --assembliesPath `"$ArtifactsDir/obj/PrepareTests`"" +
" --assembliesPath `"$ArtifactsDir/obj/RunTests`"" +
" --assembliesPath `"$ArtifactsDir/obj/vbc/$configuration/netcoreapp3.1`"" +
" --assembliesPath `"$ArtifactsDir/obj/VBCSCompiler/$configuration/netcoreapp3.1`"" +

" --debugPath `"$ArtifactsDir/BuildValidator`"" +
" --sourcePath `"$RepoRoot`"" +
" --referencesPath `"$ArtifactsDir/bin`"" +
" --referencesPath `"$dotnetInstallDir/packs/Microsoft.AspNetCore.App.Ref`"" +
" --referencesPath `"$dotnetInstallDir/packs/Microsoft.NETCore.App.Ref`"")
" --referencesPath `"$dotnetInstallDir/packs`"")
Exec-Console "$ArtifactsDir/bin/BuildValidator/$configuration/net472/BuildValidator.exe" $rebuildArgs

exit 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(RepositoryEngineeringDir)targets\ILTools.targets" />
<Import Project="$(RepositoryEngineeringDir)targets\ILAsm.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(RepositoryEngineeringDir)targets\ILTools.targets" />
<Import Project="$(RepositoryEngineeringDir)targets\ILAsm.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(RepositoryEngineeringDir)targets\ILTools.targets" />
<Import Project="$(RepositoryEngineeringDir)targets\ILAsm.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(RepositoryEngineeringDir)targets\ILTools.targets" />
<Import Project="$(RepositoryEngineeringDir)targets\ILAsm.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(RepositoryEngineeringDir)targets\ILTools.targets" />
<Import Project="$(RepositoryEngineeringDir)targets\ILAsm.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,5 @@
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(RepositoryEngineeringDir)targets\ILTools.targets" />
<Import Project="$(RepositoryEngineeringDir)targets\ILAsm.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@
<Compile Remove="Semantics\OverloadResolutionTestSource.vb" />
<Compile Remove="Semantics\PrintResultTestSource.vb" />
</ItemGroup>
<Import Project="$(RepositoryEngineeringDir)targets\ILTools.targets" />
<Import Project="$(RepositoryEngineeringDir)targets\ILAsm.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(RepositoryEngineeringDir)targets\ILTools.targets" />
<Import Project="$(RepositoryEngineeringDir)targets\ILAsm.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@
<EmbeddedResource Include="Debugging\Resources\*.*" LogicalName="Debugging/%(FileName)%(Extension)" />
</ItemGroup>
<Import Project="..\..\Analyzers\CSharp\Tests\CSharpAnalyzers.UnitTests.projitems" Label="Shared" />
<Import Project="$(RepositoryEngineeringDir)targets\ILTools.targets" />
<Import Project="$(RepositoryEngineeringDir)targets\ILAsm.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(RepositoryEngineeringDir)targets\ILTools.targets" />
<Import Project="$(RepositoryEngineeringDir)targets\ILAsm.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="..\..\Source\ResultProvider\CSharpResultProvider.projitems" Label="Shared" />
<Import Project="$(RepositoryEngineeringDir)targets\ILTools.targets" />
<Import Project="$(RepositoryEngineeringDir)targets\ILAsm.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Debugger.Engine-implementation" Version="$(MicrosoftVisualStudioDebuggerEngineimplementationVersion)" />
</ItemGroup>
<Import Project="$(RepositoryEngineeringDir)targets\ILTools.targets" />
<Import Project="$(RepositoryEngineeringDir)targets\ILAsm.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(RepositoryEngineeringDir)targets\ILTools.targets" />
<Import Project="$(RepositoryEngineeringDir)targets\ILAsm.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="..\..\Source\ResultProvider\BasicResultProvider.projitems" Label="Shared" />
<Import Project="$(RepositoryEngineeringDir)targets\ILTools.targets" />
<Import Project="$(RepositoryEngineeringDir)targets\ILAsm.targets" />
</Project>
12 changes: 8 additions & 4 deletions src/Tools/BuildValidator/BuildConstructor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,16 @@ public BuildConstructor(LocalReferenceResolver referenceResolver, LocalSourceRes
_logger = logger;
}

public Compilation CreateCompilation(CompilationOptionsReader compilationOptionsReader, string fileName)
public Compilation? CreateCompilation(CompilationOptionsReader compilationOptionsReader, string fileName)
{
var pdbCompilationOptions = compilationOptionsReader.GetMetadataCompilationOptions();
if (pdbCompilationOptions.Length == 0)
// We try to handle assemblies missing compilation options gracefully by skipping them.
// However, if an assembly has some bad combination of data, for example if it contains
// compilation options but not metadata references, then we throw an exception.
if (!compilationOptionsReader.TryGetMetadataCompilationOptions(out var pdbCompilationOptions)
|| pdbCompilationOptions.Length == 0)
{
throw new InvalidDataException("Did not find compilation options in pdb");
_logger.LogInformation($"{fileName} did not contain compilation options in its PDB");
return null;
}

var metadataReferenceInfos = compilationOptionsReader.GetMetadataReferences();
Expand Down
1 change: 1 addition & 0 deletions src/Tools/BuildValidator/BuildValidator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
<PackageReference Include="System.CommandLine" Version="$(SystemCommandLineVersion)" />
</ItemGroup>
<Import Project="$(RepositoryEngineeringDir)targets\ILDAsm.targets" />
</Project>
11 changes: 7 additions & 4 deletions src/Tools/BuildValidator/CompilationDiff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ public record BuildDataFiles(
public string OriginalPath { get; }
public ImmutableArray<Diagnostic> Diagnostics { get; }

private CompilationDiff(
string originalPath,
bool? areEqual)
private CompilationDiff(string originalPath, bool? areEqual)
{
AreEqual = areEqual;
OriginalPath = originalPath;
Expand All @@ -60,6 +58,11 @@ private CompilationDiff(ImmutableArray<Diagnostic> diagnostics, string originalP
OriginalPath = originalPath;
}

public static CompilationDiff CreatePlaceholder(FileInfo originalBinaryPath)
{
return new CompilationDiff(originalBinaryPath.FullName, areEqual: null);
}

public static unsafe CompilationDiff Create(
FileInfo originalBinaryPath,
CompilationOptionsReader optionsReader,
Expand Down Expand Up @@ -229,7 +232,7 @@ static BuildDataFiles createBuildArtifacts(string outputPath, string assemblyFil
options: pdbToXmlOptions,
methodName: null);

Process.Start(@"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\ildasm.exe", $@"{assemblyFilePath} /all /out={buildDataFiles.ILFilePath}").WaitForExit();
Process.Start(IldasmUtilities.IldasmPath, $@"{assemblyFilePath} /all /out={buildDataFiles.ILFilePath}").WaitForExit();

return buildDataFiles;
}
Expand Down
20 changes: 18 additions & 2 deletions src/Tools/BuildValidator/CompilationOptionsReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.IO.Compression;
using System.Linq;
Expand Down Expand Up @@ -77,14 +78,29 @@ public CompilationOptionsReader(ILogger logger, MetadataReader pdbReader, PERead
PeReader = peReader;
}

public bool TryGetMetadataCompilationOptionsBlobReader(out BlobReader reader)
{
return TryGetCustomDebugInformationBlobReader(CompilationOptionsGuid, out reader);
}

public BlobReader GetMetadataCompilationOptionsBlobReader()
{
if (!TryGetCustomDebugInformationBlobReader(CompilationOptionsGuid, out var optionsBlob))
if (!TryGetMetadataCompilationOptionsBlobReader(out var reader))
{
throw new InvalidOperationException();
}
return reader;
}

public bool TryGetMetadataCompilationOptions([NotNullWhen(true)] out MetadataCompilationOptions? options)
{
if (_metadataCompilationOptions is null && TryGetMetadataCompilationOptionsBlobReader(out var optionsBlob))
{
_metadataCompilationOptions = new MetadataCompilationOptions(ParseCompilationOptions(optionsBlob));
}

return optionsBlob;
options = _metadataCompilationOptions;
return options != null;
}

public MetadataCompilationOptions GetMetadataCompilationOptions()
Expand Down
42 changes: 42 additions & 0 deletions src/Tools/BuildValidator/IldasmUtilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using Roslyn.Utilities;

namespace BuildValidator
{
internal static class IldasmUtilities
{
private static string GetIldasmPath()
{
var ildasmExeName = PlatformInformation.IsWindows ? "ildasm.exe" : "ildasm";
var directory = Path.GetDirectoryName(typeof(IldasmUtilities).GetTypeInfo().Assembly.Location) ?? throw new DirectoryNotFoundException();
string ridName;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
ridName = "win-x64";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
ridName = "osx-x64";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
ridName = "linux-x64";
}
else
{
throw new PlatformNotSupportedException("Runtime platform not supported for testing");
}

return Path.Combine(directory, "runtimes", ridName, "native", ildasmExeName);
}

internal static readonly string IldasmPath = GetIldasmPath();
}
}
Loading

0 comments on commit 9438f74

Please sign in to comment.