Skip to content

Commit

Permalink
Merge pull request #932 from cake-build/feature/cake
Browse files Browse the repository at this point in the history
Cake support
  • Loading branch information
filipw authored Oct 25, 2017
2 parents 1a2d094 + 8a59058 commit 329d28a
Show file tree
Hide file tree
Showing 65 changed files with 19,163 additions and 3 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ scripts/Omnisharp*
tools/*
!tools/packages.config

# Test assets
test-assets/**/tools/*
!test-assets/**/tools/packages.config

# VS Code
/.vscode/settings.json
/.vscode/launch.json

# VS
launchSettings.json

# Rider
.idea/
30 changes: 30 additions & 0 deletions OmniSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OmniSharp.Http.Tests", "tes
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OmniSharp.DotNet.ProjectModel", "src\OmniSharp.DotNet.ProjectModel\OmniSharp.DotNet.ProjectModel.csproj", "{31580626-6D87-491D-A65E-F6B881164398}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OmniSharp.Cake", "src\OmniSharp.Cake\OmniSharp.Cake.csproj", "{BA0713A6-EF63-419D-B60D-7A84B134531F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OmniSharp.Cake.Tests", "tests\OmniSharp.Cake.Tests\OmniSharp.Cake.Tests.csproj", "{17DAECA3-AE28-4B40-AA52-1EF618346A85}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -327,6 +331,30 @@ Global
{31580626-6D87-491D-A65E-F6B881164398}.Release|x64.Build.0 = Release|Any CPU
{31580626-6D87-491D-A65E-F6B881164398}.Release|x86.ActiveCfg = Release|Any CPU
{31580626-6D87-491D-A65E-F6B881164398}.Release|x86.Build.0 = Release|Any CPU
{BA0713A6-EF63-419D-B60D-7A84B134531F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BA0713A6-EF63-419D-B60D-7A84B134531F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BA0713A6-EF63-419D-B60D-7A84B134531F}.Debug|x64.ActiveCfg = Debug|Any CPU
{BA0713A6-EF63-419D-B60D-7A84B134531F}.Debug|x64.Build.0 = Debug|Any CPU
{BA0713A6-EF63-419D-B60D-7A84B134531F}.Debug|x86.ActiveCfg = Debug|Any CPU
{BA0713A6-EF63-419D-B60D-7A84B134531F}.Debug|x86.Build.0 = Debug|Any CPU
{BA0713A6-EF63-419D-B60D-7A84B134531F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BA0713A6-EF63-419D-B60D-7A84B134531F}.Release|Any CPU.Build.0 = Release|Any CPU
{BA0713A6-EF63-419D-B60D-7A84B134531F}.Release|x64.ActiveCfg = Release|Any CPU
{BA0713A6-EF63-419D-B60D-7A84B134531F}.Release|x64.Build.0 = Release|Any CPU
{BA0713A6-EF63-419D-B60D-7A84B134531F}.Release|x86.ActiveCfg = Release|Any CPU
{BA0713A6-EF63-419D-B60D-7A84B134531F}.Release|x86.Build.0 = Release|Any CPU
{17DAECA3-AE28-4B40-AA52-1EF618346A85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{17DAECA3-AE28-4B40-AA52-1EF618346A85}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17DAECA3-AE28-4B40-AA52-1EF618346A85}.Debug|x64.ActiveCfg = Debug|Any CPU
{17DAECA3-AE28-4B40-AA52-1EF618346A85}.Debug|x64.Build.0 = Debug|Any CPU
{17DAECA3-AE28-4B40-AA52-1EF618346A85}.Debug|x86.ActiveCfg = Debug|Any CPU
{17DAECA3-AE28-4B40-AA52-1EF618346A85}.Debug|x86.Build.0 = Debug|Any CPU
{17DAECA3-AE28-4B40-AA52-1EF618346A85}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17DAECA3-AE28-4B40-AA52-1EF618346A85}.Release|Any CPU.Build.0 = Release|Any CPU
{17DAECA3-AE28-4B40-AA52-1EF618346A85}.Release|x64.ActiveCfg = Release|Any CPU
{17DAECA3-AE28-4B40-AA52-1EF618346A85}.Release|x64.Build.0 = Release|Any CPU
{17DAECA3-AE28-4B40-AA52-1EF618346A85}.Release|x86.ActiveCfg = Release|Any CPU
{17DAECA3-AE28-4B40-AA52-1EF618346A85}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -353,6 +381,8 @@ Global
{0A9BF1CC-2F0D-431C-BAFD-403658E233F1} = {2C348365-A9D8-459E-9276-56FC46AAEE31}
{1217C534-E8EB-454D-B6E1-12BD30E72F8E} = {35E025BF-BBB2-4FAC-9F4B-37CBA083EE47}
{31580626-6D87-491D-A65E-F6B881164398} = {2C348365-A9D8-459E-9276-56FC46AAEE31}
{BA0713A6-EF63-419D-B60D-7A84B134531F} = {2C348365-A9D8-459E-9276-56FC46AAEE31}
{17DAECA3-AE28-4B40-AA52-1EF618346A85} = {35E025BF-BBB2-4FAC-9F4B-37CBA083EE47}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4DD725CE-B49A-4151-8B77-BB33FE88E46E}
Expand Down
18 changes: 18 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,24 @@ Task("PrepareTestAssets")
.ExceptionOnError($"Failed to build '{folder}'.");
}
}

// Restore Cake test assets with NuGet
foreach (var project in buildPlan.CakeTestAssets)
{
Information("Restoring: {0}...", project);

var toolsFolder = CombinePaths(env.Folders.TestAssets, "test-projects", project, "tools");
var packagesConfig = CombinePaths(toolsFolder, "packages.config");

NuGetInstallFromConfig(packagesConfig, new NuGetInstallSettings {
OutputDirectory = toolsFolder,
Prerelease = true,
Verbosity = NuGetVerbosity.Quiet,
Source = new[] {
"https://api.nuget.org/v3/index.json"
}
});
}
});

void BuildProject(BuildEnvironment env, string projectName, string projectFilePath, string configuration, string outputType = null)
Expand Down
6 changes: 5 additions & 1 deletion build.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"OmniSharp.Stdio.Tests",
"OmniSharp.DotNet.Tests",
"OmniSharp.DotNetTest.Tests",
"OmniSharp.Tests"
"OmniSharp.Tests",
"OmniSharp.Cake.Tests"
],
"TestAssets": [
"NUnitTestProject",
Expand All @@ -42,5 +43,8 @@
"LegacyXunitTestProject",
"LegacyMSTestProject",
"LegacyProjectJsonApp"
],
"CakeTestAssets": [
"CakeProject"
]
}
3 changes: 2 additions & 1 deletion build/Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<CakeScriptinTransportVersion>0.1.0</CakeScriptinTransportVersion>
<DotnetScriptDependencyModelVersion>0.1.0</DotnetScriptDependencyModelVersion>
<DotnetScriptDependencyModelNuGetVersion>0.1.0</DotnetScriptDependencyModelNuGetVersion>
<DotnetScriptDependencyModelNuGetVersion>0.1.0</DotnetScriptDependencyModelNuGetVersion>
<MicrosoftAspNetCoreDiagnosticsVersion>1.1.0</MicrosoftAspNetCoreDiagnosticsVersion>
<MicrosoftAspNetCoreHostingVersion>1.1.0</MicrosoftAspNetCoreHostingVersion>
<MicrosoftAspNetCoreHttpFeaturesVersion>1.1.0</MicrosoftAspNetCoreHttpFeaturesVersion>
Expand Down
1 change: 1 addition & 0 deletions scripts/common.cake
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ public class BuildPlan
public string[] TestProjects { get; set; }
public string[] TestAssets { get; set; }
public string[] LegacyTestAssets { get; set; }
public string[] CakeTestAssets { get; set; }

public static BuildPlan Load(BuildEnvironment env)
{
Expand Down
3 changes: 3 additions & 0 deletions src/OmniSharp.Cake/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("OmniSharp.Cake.Tests")]
59 changes: 59 additions & 0 deletions src/OmniSharp.Cake/CachingScriptMetadataResolver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Scripting;

namespace OmniSharp.Cake
{
internal class CachingScriptMetadataResolver : MetadataReferenceResolver
{
private static readonly Dictionary<string, ImmutableArray<PortableExecutableReference>> DirectReferenceCache = new Dictionary<string, ImmutableArray<PortableExecutableReference>>();
private static readonly Dictionary<string, PortableExecutableReference> MissingReferenceCache = new Dictionary<string, PortableExecutableReference>();
private static readonly MetadataReferenceResolver DefaultRuntimeResolver = ScriptMetadataResolver.Default;

public override bool Equals(object other)
{
return DefaultRuntimeResolver.Equals(other);
}

public override int GetHashCode()
{
return DefaultRuntimeResolver.GetHashCode();
}

public override bool ResolveMissingAssemblies => DefaultRuntimeResolver.ResolveMissingAssemblies;

public override PortableExecutableReference ResolveMissingAssembly(MetadataReference definition, AssemblyIdentity referenceIdentity)
{
if (MissingReferenceCache.TryGetValue(referenceIdentity.Name, out var result))
{
return result;
}

result = DefaultRuntimeResolver.ResolveMissingAssembly(definition, referenceIdentity);
if (result != null)
{
MissingReferenceCache[referenceIdentity.Name] = result;
}

return result;
}

public override ImmutableArray<PortableExecutableReference> ResolveReference(string reference, string baseFilePath, MetadataReferenceProperties properties)
{
var key = $"{reference}-{baseFilePath}";
if (DirectReferenceCache.TryGetValue(key, out var result))
{
return result;
}

result = DefaultRuntimeResolver.ResolveReference(reference, baseFilePath, properties);
if (result.Length > 0)
{
DirectReferenceCache[key] = result;
}

return result;
}
}
}
12 changes: 12 additions & 0 deletions src/OmniSharp.Cake/CakeContextModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace OmniSharp.Cake
{
internal class CakeContextModel
{
public CakeContextModel(string filePath)
{
Path = filePath;
}

public string Path { get; }
}
}
14 changes: 14 additions & 0 deletions src/OmniSharp.Cake/CakeContextModelCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Collections.Generic;

namespace OmniSharp.Cake
{
internal class CakeContextModelCollection
{
public CakeContextModelCollection(IEnumerable<CakeContextModel> projects)
{
Projects = projects;
}

public IEnumerable<CakeContextModel> Projects { get; }
}
}
Loading

0 comments on commit 329d28a

Please sign in to comment.