Skip to content

Commit 7d464be

Browse files
authored
Add support for creating an isolated solution from a binlog (#75)
* Add support for creating an isolated solution from a binlog * Normalize solutionName
1 parent 2be8e14 commit 7d464be

23 files changed

+733
-196
lines changed

Directory.Build.props

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project>
2+
<PropertyGroup>
3+
<VersionSuffix>$(BUILD_BUILDNUMBER)</VersionSuffix>
4+
<VersionSuffix Condition="'$(VersionSuffix)' == ''">dev</VersionSuffix>
5+
6+
<LangVersion>latest</LangVersion>
7+
</PropertyGroup>
8+
</Project>

azure-pipelines.yml

+18
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ jobs:
1717

1818
timeoutInMinutes: 960
1919

20+
variables:
21+
- group: source-dot-net stage1 variables
22+
2023
steps:
2124
- checkout: self
2225
clean: true
@@ -50,6 +53,19 @@ jobs:
5053
projects: |
5154
**\*.sln
5255
56+
- task: DotNetCoreCLI@2
57+
inputs:
58+
command: 'build'
59+
projects: '**\*.sln'
60+
arguments: '/p:PackageOutputPath=$(Build.ArtifactStagingDirectory)/packages'
61+
62+
- task: NuGetCommand@2
63+
inputs:
64+
command: 'push'
65+
packagesToPush: '$(Build.ArtifactStagingDirectory)/packages/*.nupkg'
66+
nuGetFeedType: 'internal'
67+
publishVstsFeed: 'dotnet-tools'
68+
5369
- task: VSBuild@1
5470
displayName: Clone All Repositories
5571
inputs:
@@ -98,6 +114,8 @@ jobs:
98114
solution: build.proj
99115
msbuildArgs: /t:Build
100116
msbuildArchitecture: x64
117+
env:
118+
source-dot-net-stage1-blob-container-url: $(source-dot-net-stage1-blob-container-url)
101119

102120
- powershell: |
103121
deployment/install-tool.ps1 -Name 'azure-cli' -Version 2.8.0 -TestPath '/wbin/az.cmd' -BinPath '/wbin/'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using System;
2+
using System.IO;
3+
using System.Linq;
4+
using System.Text;
5+
using Azure;
6+
using Azure.Storage.Blobs;
7+
using Azure.Storage.Blobs.Models;
8+
using ICSharpCode.SharpZipLib.GZip;
9+
using ICSharpCode.SharpZipLib.Tar;
10+
using Microsoft.Build.Framework;
11+
using Microsoft.Build.Utilities;
12+
13+
namespace Microsoft.SourceIndexer.Tasks
14+
{
15+
public class DownloadStage1Index : Task
16+
{
17+
[Required]
18+
public string BlobContainerSasUrl { get; set; }
19+
20+
[Required]
21+
public string RepoName { get; set; }
22+
23+
[Required]
24+
public string OutputDirectory { get; set; }
25+
26+
public override bool Execute()
27+
{
28+
try
29+
{
30+
ExecuteCore();
31+
}
32+
catch (Exception ex)
33+
{
34+
Log.LogErrorFromException(ex, true);
35+
}
36+
return !Log.HasLoggedErrors;
37+
}
38+
39+
private void ExecuteCore()
40+
{
41+
var containerClient = new BlobContainerClient(new Uri(BlobContainerSasUrl));
42+
Pageable<BlobItem> blobs = containerClient.GetBlobs(prefix: RepoName + "/");
43+
BlobItem newest = blobs.OrderByDescending(b => b.Name).FirstOrDefault();
44+
if (newest == null)
45+
{
46+
Log.LogError($"Unable to find stage1 output for repo {RepoName}");
47+
return;
48+
}
49+
50+
BlobClient blobClient = containerClient.GetBlobClient(newest.Name);
51+
var loggableUrl = new UriBuilder(blobClient.Uri) {Fragment = "", Query = ""};
52+
Log.LogMessage($"Extracting {blobClient.Uri} to {OutputDirectory}");
53+
using Stream fileStream = blobClient.OpenRead();
54+
using var input = new GZipInputStream(fileStream);
55+
using var archive = TarArchive.CreateInputTarArchive(input, Encoding.UTF8);
56+
archive.ExtractContents(OutputDirectory, false);
57+
}
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,12 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
1+
<Project Sdk="Microsoft.NET.Sdk">
42
<PropertyGroup>
5-
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
6-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
8-
<ProjectGuid>{5D86D28A-FEB9-4561-8EA8-D3C3BB409FB3}</ProjectGuid>
9-
<OutputType>Library</OutputType>
10-
<RootNamespace>Microsoft.SourceIndexer.Tasks</RootNamespace>
11-
<AssemblyName>Microsoft.SourceIndexer.Tasks</AssemblyName>
12-
<DefaultLanguage>en-US</DefaultLanguage>
13-
<FileAlignment>512</FileAlignment>
14-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
15-
<NuGetTargetMoniker>.NETFramework,Version=v4.5</NuGetTargetMoniker>
3+
<TargetFramework>net472</TargetFramework>
164
</PropertyGroup>
17-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18-
<DebugSymbols>true</DebugSymbols>
19-
<DebugType>full</DebugType>
20-
<Optimize>false</Optimize>
21-
<OutputPath>bin\Debug\</OutputPath>
22-
<DefineConstants>DEBUG;TRACE</DefineConstants>
23-
<ErrorReport>prompt</ErrorReport>
24-
<WarningLevel>4</WarningLevel>
25-
</PropertyGroup>
26-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27-
<DebugType>pdbonly</DebugType>
28-
<Optimize>true</Optimize>
29-
<OutputPath>bin\Release\</OutputPath>
30-
<DefineConstants>TRACE</DefineConstants>
31-
<ErrorReport>prompt</ErrorReport>
32-
<WarningLevel>4</WarningLevel>
33-
</PropertyGroup>
34-
<ItemGroup>
35-
<None Include="project.json" />
36-
</ItemGroup>
37-
<ItemGroup>
38-
<Compile Include="Extensions.cs" />
39-
<Compile Include="SelectProjects.cs" />
40-
</ItemGroup>
415
<ItemGroup>
42-
<Reference Include="Microsoft.Build" />
43-
<Reference Include="Microsoft.Build.Conversion.v4.0" />
44-
<Reference Include="Microsoft.Build.Engine" />
45-
<Reference Include="Microsoft.Build.Framework" />
46-
<Reference Include="Microsoft.Build.Tasks.v4.0" />
47-
<Reference Include="Microsoft.Build.Utilities.v4.0" />
48-
<Reference Include="System" />
49-
<Reference Include="System.Core" />
6+
<PackageReference Include="Azure.Storage.Blobs" Version="12.7.0" />
7+
<PackageReference Include="Microsoft.Build.Framework" Version="16.8.0" />
8+
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="16.8.0" />
9+
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.8.0" />
10+
<PackageReference Include="SharpZipLib" Version="1.3.1" />
5011
</ItemGroup>
51-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.Targets" />
52-
</Project>
12+
</Project>

src/Microsoft.SourceIndexer.Tasks/project.json

-17
This file was deleted.

src/SourceBrowser/SourceBrowser.sln

+20-5
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26228.9
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30503.244
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlGenerator", "src\HtmlGenerator\HtmlGenerator.csproj", "{3CB763A5-A0C0-46B0-AEF5-020E731253C2}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlGenerator", "src\HtmlGenerator\HtmlGenerator.csproj", "{3CB763A5-A0C0-46B0-AEF5-020E731253C2}"
77
EndProject
88
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildLogParser", "src\BuildLogParser\BuildLogParser.csproj", "{57002F26-8D15-4CF7-A53D-61AE8CC5E836}"
99
EndProject
1010
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Common", "src\Common\Common.csproj", "{F13CD277-E86B-4BC6-9E93-39ED055A46DB}"
1111
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitGlyph", "src\GitGlyph\GitGlyph.csproj", "{810A96AB-58EB-4403-9A1E-964F85958E62}"
12+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitGlyph", "src\GitGlyph\GitGlyph.csproj", "{810A96AB-58EB-4403-9A1E-964F85958E62}"
1313
EndProject
1414
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MEF", "src\MEF\MEF.csproj", "{E3411353-9F6B-4FB2-874E-106BF4896462}"
1515
EndProject
1616
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SourceIndexServer", "src\SourceIndexServer\SourceIndexServer.csproj", "{018CE264-C76D-4448-BB0A-89A25F1088A2}"
1717
EndProject
1818
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlGenerator.Tests", "src\HtmlGenerator.Tests\HtmlGenerator.Tests.csproj", "{4EDEE974-055C-455E-866F-4BDCB734CB59}"
1919
EndProject
20-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceIndexServer.Tests", "src\SourceIndexServer.Tests\SourceIndexServer.Tests.csproj", "{37B5A89F-5436-45BE-B782-C476086A6AF8}"
20+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SourceIndexServer.Tests", "src\SourceIndexServer.Tests\SourceIndexServer.Tests.csproj", "{37B5A89F-5436-45BE-B782-C476086A6AF8}"
21+
EndProject
22+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BinLogParser", "src\BinLogParser\BinLogParser.csproj", "{4EF5052C-7D88-49C6-B940-5190CECD070D}"
23+
EndProject
24+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BinLogToSln", "src\BinLogToSln\BinLogToSln.csproj", "{E73D1784-F1BC-4F01-B68E-03623CFBFB8E}"
2125
EndProject
2226
Global
2327
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -57,8 +61,19 @@ Global
5761
{37B5A89F-5436-45BE-B782-C476086A6AF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
5862
{37B5A89F-5436-45BE-B782-C476086A6AF8}.Release|Any CPU.ActiveCfg = Release|Any CPU
5963
{37B5A89F-5436-45BE-B782-C476086A6AF8}.Release|Any CPU.Build.0 = Release|Any CPU
64+
{4EF5052C-7D88-49C6-B940-5190CECD070D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
65+
{4EF5052C-7D88-49C6-B940-5190CECD070D}.Debug|Any CPU.Build.0 = Debug|Any CPU
66+
{4EF5052C-7D88-49C6-B940-5190CECD070D}.Release|Any CPU.ActiveCfg = Release|Any CPU
67+
{4EF5052C-7D88-49C6-B940-5190CECD070D}.Release|Any CPU.Build.0 = Release|Any CPU
68+
{E73D1784-F1BC-4F01-B68E-03623CFBFB8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
69+
{E73D1784-F1BC-4F01-B68E-03623CFBFB8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
70+
{E73D1784-F1BC-4F01-B68E-03623CFBFB8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
71+
{E73D1784-F1BC-4F01-B68E-03623CFBFB8E}.Release|Any CPU.Build.0 = Release|Any CPU
6072
EndGlobalSection
6173
GlobalSection(SolutionProperties) = preSolution
6274
HideSolutionNode = FALSE
6375
EndGlobalSection
76+
GlobalSection(ExtensibilityGlobals) = postSolution
77+
SolutionGuid = {AEF73422-12DC-438A-BB7C-A7652A235284}
78+
EndGlobalSection
6479
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<AssemblyName>BinLogParser</AssemblyName>
6+
<RootNamespace>Microsoft.SourceBrowser.BinLogParser</RootNamespace>
7+
</PropertyGroup>
8+
9+
<PropertyGroup>
10+
<NuGetVersionRoslyn>3.9.0-2.final</NuGetVersionRoslyn>
11+
</PropertyGroup>
12+
13+
14+
<ItemGroup>
15+
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="$(NuGetVersionRoslyn)" />
16+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(NuGetVersionRoslyn)" />
17+
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="$(NuGetVersionRoslyn)" />
18+
<PackageReference Include="MSBuild.StructuredLogger" Version="2.1.215" />
19+
</ItemGroup>
20+
21+
22+
<ItemGroup>
23+
<ProjectReference Include="..\Common\Common.csproj" />
24+
</ItemGroup>
25+
26+
</Project>

src/SourceBrowser/src/HtmlGenerator/Utilities/BinLogReader.cs src/SourceBrowser/src/BinLogParser/BinLogReader.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22
using System.Collections.Concurrent;
33
using System.Collections.Generic;
44
using System.IO;
5-
using System.Linq;
65
using Microsoft.Build.Framework;
76
using Microsoft.CodeAnalysis;
8-
using Microsoft.SourceBrowser.Common;
9-
using CompilerInvocation = Microsoft.SourceBrowser.HtmlGenerator.GenerateFromBuildLog.CompilerInvocation;
107

11-
namespace Microsoft.SourceBrowser.HtmlGenerator
8+
namespace Microsoft.SourceBrowser.BinLogParser
129
{
1310
public enum CompilerKind
1411
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Runtime.InteropServices;
6+
using Microsoft.CodeAnalysis;
7+
using Microsoft.CodeAnalysis.CSharp;
8+
using Microsoft.CodeAnalysis.VisualBasic;
9+
10+
namespace Microsoft.SourceBrowser.BinLogParser
11+
{
12+
public class CompilerInvocation
13+
{
14+
public string ProjectFilePath { get; set; }
15+
public string ProjectDirectory => ProjectFilePath == null ? "" : Path.GetDirectoryName(ProjectFilePath);
16+
public string OutputAssemblyPath { get; set; }
17+
public string CommandLineArguments { get; set; }
18+
public string ServerPath { get; set; }
19+
public string NetworkShare { get; set; }
20+
public string SolutionRoot { get; set; }
21+
public IEnumerable<string> TypeScriptFiles { get; set; }
22+
23+
public string AssemblyName => Path.GetFileNameWithoutExtension(OutputAssemblyPath);
24+
25+
private string language;
26+
public string Language
27+
{
28+
get
29+
{
30+
if (language == null)
31+
{
32+
if (ProjectFilePath == null && TypeScriptFiles != null)
33+
{
34+
language = "TypeScript";
35+
}
36+
else if (".vbproj".Equals(Path.GetExtension(ProjectFilePath), StringComparison.OrdinalIgnoreCase))
37+
{
38+
language = "Visual Basic";
39+
}
40+
else
41+
{
42+
language = "C#";
43+
}
44+
}
45+
46+
return language;
47+
}
48+
49+
set
50+
{
51+
language = value;
52+
}
53+
}
54+
55+
private string[] GetCommandLineArguments()
56+
{
57+
return CommandLineParser.SplitCommandLineIntoArguments(CommandLineArguments, removeHashComments: false).ToArray();
58+
}
59+
60+
private CommandLineArguments parsed;
61+
public CommandLineArguments Parsed
62+
{
63+
get
64+
{
65+
if (parsed != null)
66+
{
67+
return parsed;
68+
}
69+
70+
var sdkDirectory = RuntimeEnvironment.GetRuntimeDirectory();
71+
var args = GetCommandLineArguments();
72+
73+
if (Language == LanguageNames.CSharp)
74+
{
75+
parsed = CSharpCommandLineParser.Default.Parse(args, ProjectDirectory, sdkDirectory);
76+
}
77+
else
78+
{
79+
parsed = VisualBasicCommandLineParser.Default.Parse(args, ProjectDirectory, sdkDirectory);
80+
}
81+
82+
return parsed;
83+
}
84+
}
85+
86+
public override string ToString()
87+
{
88+
return CommandLineArguments;
89+
}
90+
}
91+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
6+
<PackAsTool>true</PackAsTool>
7+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="LibGit2Sharp" Version="0.26.2" />
12+
<PackageReference Include="Mono.Options" Version="6.6.0.161" />
13+
<PackageReference Include="System.Reflection.Metadata" Version="5.0.0" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\BinLogParser\BinLogParser.csproj" />
18+
</ItemGroup>
19+
20+
</Project>

0 commit comments

Comments
 (0)