mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
* convert to VS2017 * rework cake.frosting build to latest cake vs2017 "template" example * fix clean task and version suffix * add arg to DotNetCorePack so it uses the correct version * fix appveyor * is there an easier way to test appveyor? * ok travis, let's do this * after reading the travis repo, this seems to be the version we want for vs201/csproj tool support * msbuild complaining about arguments - we can use defaults anyhow so remove $@ from build.sh script * add workaround for msbuild/travis, as mentioned on aspnet Mvc repo * cmon travis * perhaps tee isnt needed afterall * travis permission denied when trying to install tools in build script... i feel dirty but need to see if sudo will fix it! * could it be folder permissions of /build ? * Try 777 for NuGet.exe permissions rather than 644 * remove windows platform restriction on GitVersion call * Add a wrapper script for GitVersion on non windows * fix wrapper script name * add debug * let's see if we are running the script at all! * run mono gitversion direclty from travis.yml, for science * see if we can run bin/sh and prepend an argument to our shell script * remove echos from wrapper script * Ensure full git repo include more than 50 commits and all tags are fetched, as GitVersion was failing on TravisCI * only build netstandard framework on non windows * revert overriding the target framework when building the solution * Unix being case-sensitive, adjust app.config file name in csproj files * set FrameworkPathOverride to point to different folders on macOS and Linux * Remove NuGet.exe from the repo. On Windows, it will be installed by the Frosting bootstrapper script. On Unix/macOS, cake has smarts to look for mono- and Linux-specific executables * tidy up GitVersion logic into a GitVersionRunner class * apply workaround for osx dotnet restore "too many open files" errors * update test project references to latest official versions * doesnt seem to be a reason for overriding the implicit reference * remove extra whitespace and unused namespace
114 lines
3.8 KiB
C#
114 lines
3.8 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Xml.Linq;
|
|
using Cake.Common;
|
|
using Cake.Common.Diagnostics;
|
|
using Cake.Core;
|
|
using Cake.Core.IO;
|
|
using Cake.Frosting;
|
|
|
|
[Dependency(typeof(Build))]
|
|
public sealed class ValidateLINQPadSamples : FrostingTask<Context>
|
|
{
|
|
public override void Run(Context context)
|
|
{
|
|
var assembliesDirectoryPath = context.Environment.WorkingDirectory
|
|
.Combine("Octokit.Reactive")
|
|
.Combine("bin")
|
|
.Combine(context.Configuration)
|
|
.Combine("net45")
|
|
.MakeAbsolute(context.Environment)
|
|
.FullPath;
|
|
|
|
var linqpadSamples = context.FileSystem
|
|
.GetDirectory("samples/linqpad-samples")
|
|
.GetFiles("*.linq", SearchScope.Current)
|
|
.Select(x => x.Path)
|
|
.ToArray();
|
|
|
|
var linqpadExe = context.Environment.WorkingDirectory
|
|
.Combine("tools")
|
|
.Combine("LINQPad")
|
|
.CombineWithFilePath("lprun.exe")
|
|
.MakeAbsolute(context.Environment);
|
|
|
|
foreach (var linqpadSample in linqpadSamples)
|
|
{
|
|
var sampleName = linqpadSample.GetFilename();
|
|
var rewrittenSample = RewriteLinqpadScriptToUseLocalAssemblies(assembliesDirectoryPath, linqpadSample.FullPath);
|
|
|
|
context.Information("Executing sample {0}...", sampleName);
|
|
var exitCode = context.StartProcess(
|
|
linqpadExe,
|
|
$"-compileonly -lang=Program {rewrittenSample}");
|
|
|
|
if (exitCode != 0)
|
|
{
|
|
throw new CakeException($"Execution of sample {sampleName} failed");
|
|
}
|
|
}
|
|
|
|
context.Information("All samples executed successfully");
|
|
}
|
|
|
|
public override bool ShouldRun(Context context)
|
|
{
|
|
return context.IsRunningOnWindows();
|
|
}
|
|
|
|
private static string RewriteLinqpadScriptToUseLocalAssemblies(string directory, string filePath)
|
|
{
|
|
var text = File.ReadAllText(filePath);
|
|
|
|
var openTag = "<Query Kind=\"Program\">";
|
|
var openTagIndex = text.IndexOf(openTag);
|
|
var closeTag = "</Query>";
|
|
var closeTagIndex = text.IndexOf(closeTag);
|
|
|
|
if (openTagIndex == -1 || closeTagIndex == -1)
|
|
{
|
|
throw new InvalidOperationException();
|
|
}
|
|
|
|
var endOfMetadata = closeTagIndex + closeTag.Length;
|
|
|
|
// write to temp file on disk
|
|
var tempFilePath = System.IO.Path.GetTempFileName();
|
|
|
|
using (var stream = File.OpenWrite(tempFilePath))
|
|
using (var writer = new StreamWriter(stream))
|
|
{
|
|
// reference all known assemblies
|
|
writer.WriteLine("ref {0}\\System.Reactive.Core.dll;", directory);
|
|
writer.WriteLine("ref {0}\\System.Reactive.Interfaces.dll;", directory);
|
|
writer.WriteLine("ref {0}\\System.Reactive.Linq.dll;", directory);
|
|
writer.WriteLine("ref {0}\\Octokit.dll;", directory);
|
|
writer.WriteLine("ref {0}\\Octokit.Reactive.dll;", directory);
|
|
writer.WriteLine("ref C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.5\\System.Net.Http.dll;");
|
|
writer.WriteLine();
|
|
|
|
var xmlText = text.Substring(openTagIndex, endOfMetadata);
|
|
var rest = text.Substring(endOfMetadata);
|
|
|
|
var doc = XDocument.Parse(xmlText);
|
|
|
|
// add namespaces specified in xml
|
|
var namespaces = doc.Descendants()
|
|
.Where(x => x.Name == "Namespace")
|
|
.Select(x => x.Value.ToString());
|
|
|
|
foreach (var @namespace in namespaces)
|
|
{
|
|
writer.WriteLine("using {0};", @namespace);
|
|
}
|
|
|
|
writer.WriteLine();
|
|
writer.WriteLine(rest);
|
|
|
|
writer.Flush();
|
|
}
|
|
|
|
return tempFilePath;
|
|
}
|
|
} |