Ejemplo n.º 1
0
        static partial void PreProcess(InspectCodeSettings toolSettings)
        {
            var installedPlugins = GetInstalledPlugins();

            if (installedPlugins.Count == 0 && toolSettings.Extensions.Count == 0)
            {
                return;
            }

            var shadowDirectory = GetShadowDirectory(toolSettings, installedPlugins);

            FileSystemTasks.CopyRecursively(
                Path.GetDirectoryName(toolSettings.ToolPath).NotNull(),
                shadowDirectory,
                FileSystemTasks.FileExistsPolicy.OverwriteIfNewer);

            installedPlugins.Select(x => x.FileName)
            .ForEach(x => File.Copy(x, Path.Combine(shadowDirectory, Path.GetFileName(x).NotNull()), overwrite: true));

#if !NETCORE
            toolSettings.Extensions.ForEach(x => HttpTasks.HttpDownloadFile(
                                                $"https://resharper-plugins.jetbrains.com/api/v2/package/{x}",
                                                Path.Combine(shadowDirectory, $"{x}.nupkg")));
#else
            ControlFlow.Assert(toolSettings.Extensions.Count == 0,
                               "InspectCodeSettings.Extensions is currently not supported on .NET Core. However, after adding the ReSharper gallery feed " +
                               "(https://resharper-plugins.jetbrains.com/api/v2), you can reference them as normal NuGet packages in your project file.");
#endif
        }
Ejemplo n.º 2
0
        private static void PreProcess(ref CleanupCodeSettings toolSettings)
        {
            var installedPlugins = GetInstalledPlugins();

            if (installedPlugins.Count == 0 && toolSettings.Extensions.Count == 0)
            {
                return;
            }

            var shadowDirectory = GetShadowDirectory(installedPlugins);

            FileSystemTasks.CopyDirectoryRecursively(
                Path.GetDirectoryName(toolSettings.ToolPath).NotNull(),
                shadowDirectory,
                DirectoryExistsPolicy.Merge,
                FileExistsPolicy.OverwriteIfNewer
                );

            installedPlugins.Select(x => x.FileName)
            .ForEach(x => File.Copy(x, Path.Combine(shadowDirectory, Path.GetFileName(x).NotNull()), true));

            toolSettings.Extensions.ForEach(
                x => HttpTasks.HttpDownloadFile(
                    $"https://resharper-plugins.jetbrains.com/api/v2/package/{x}",
                    Path.Combine(shadowDirectory, $"{x}.nupkg")
                    )
                );
        }
        private void InstallDotNetRuntime()
        {
            HttpTasks.HttpDownloadFile(ScriptUrl, ScriptFile);

            var version          = GetDotNetRuntimeVersion();
            var installLocation  = Constants.GlobalNukeDirectory / "dotnet-runtime" / (version ?? "current");
            var dotnetExecutable = installLocation / (EnvironmentInfo.IsWin ? "dotnet.exe" : "dotnet");

            if (version == null || !File.Exists(dotnetExecutable))
            {
                if (EnvironmentInfo.IsLinux)
                {
                    ProcessTasks.StartShell($"chmod +x {ScriptFile.ToString().DoubleQuoteIfNeeded()}", logOutput: false)
                    .AssertZeroExitCode();
                }

                ProcessTasks.StartShell(
                    EnvironmentInfo.IsWin
                            ? $"powershell {ScriptFile.ToString().DoubleQuoteIfNeeded()} -InstallDir {installLocation} -NoPath -Runtime dotnet "
                    + (version != null ? $"-Version {version}" : "-Channel Current")
                            : $"{ScriptFile.ToString().DoubleQuoteIfNeeded()} --install-dir {installLocation} --no-path --runtime dotnet "
                    + (version != null ? $"--version {version}" : "--channel Current"),
                    logOutput: false)
                .AssertZeroExitCode();
            }

            EnvironmentInfo.SetVariable("DOTNET_EXE", dotnetExecutable);
            EnvironmentInfo.SetVariable("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", value: true);
        }
Ejemplo n.º 4
0
        public bool Execute()
        {
            var metadataFiles = MetadataFiles.Select(x => x.GetMetadata("Fullpath")).ToList();

            if (!MetadataFiles.Any())
            {
                ControlFlow.SuppressErrors(() =>
                {
                    var exampleFile = Path.Combine(BaseDirectory, "RandomTool.json");
                    HttpTasks.HttpDownloadFile(c_exampleUrl, exampleFile);
                    metadataFiles.Add(exampleFile);
                });
            }

            CodeGenerator.GenerateCode(
                metadataFiles,
                BaseDirectory,
                UseNestedNamespaces,
                BaseNamespace,
                GitRepository.FromLocalDirectory(BaseDirectory));

            if (UpdateReferences)
            {
                ReferenceUpdater.UpdateReferences(metadataFiles);
            }

            return(true);
        }
Ejemplo n.º 5
0
    public override object GetValue(MemberInfo member, object instance)
    {
        var rssFile = NukeBuild.TemporaryDirectory / $"{_groupId}-{_artifactId ?? _groupId}.xml";

        HttpTasks.HttpDownloadFile($"https://{_repository.TrimStart("https").TrimStart("http").TrimStart("://").TrimEnd("/")}/m2/{_groupId.Replace(".", "/")}/{_artifactId ?? _groupId}/maven-metadata.xml", rssFile);
        return(XmlTasks.XmlPeek(rssFile, ".//version").Last());
    }
    public override object GetValue(MemberInfo member, object instance)
    {
        var rssFile = NukeBuild.TemporaryDirectory / $"{_feed}.xml";

        HttpTasks.HttpDownloadFile($"https://www.myget.org/RSS/{_feed}", rssFile);
        return(XmlTasks.XmlPeek(rssFile, ".//title")
               // TODO: regex?
               .First(x => x.Contains($"/{_package} "))
               .Split('(').Last()
               .Split(')').First()
               .TrimStart("version "));
    }
Ejemplo n.º 7
0
        public void Execute()
        {
            if (_downloadSchema)
            {
                ControlFlow.SuppressErrors(() =>
                                           HttpTasks.HttpDownloadFile(c_schemaDownloadUrl, (RelativePath)_metadataDirectory / c_schemaFileName));
            }

            var files = Directory.GetFiles(_metadataDirectory, "*.json", SearchOption.TopDirectoryOnly).Where(x => !x.EndsWith(c_schemaFileName));

            files.AsParallel().ForAll(HandleFile);
        }
Ejemplo n.º 8
0
        public static void DownloadIfNotExists(string src, string dst, string label = null)
        {
            var textLabel = string.IsNullOrEmpty(label) ? string.Empty : $"{label}; ";

            if (File.Exists(dst) == false)
            {
                Serilog.Log.Debug($"{textLabel}File do not exists; Downloading; Src: {src}; Dst: {dst}");
                HttpTasks.HttpDownloadFile(src, dst);
            }
            else
            {
                Serilog.Log.Debug($"{textLabel}File exists; Path: {dst}");
            }
        }
Ejemplo n.º 9
0
        private static void PreProcess <T>(ref T toolSettings) where T : ReSharperSettingsBase
        {
            if (toolSettings.Plugins.Count == 0)
            {
                return;
            }

            var wave            = GetWave(toolSettings).NotNull("wave != null");
            var shadowDirectory = GetShadowDirectory(toolSettings, wave);

            FileSystemTasks.CopyDirectoryRecursively(
                Path.GetDirectoryName(toolSettings.ProcessToolPath).NotNull(),
                shadowDirectory,
                DirectoryExistsPolicy.Merge,
                FileExistsPolicy.OverwriteIfNewer);

            toolSettings.Plugins.ForEach(x => HttpTasks.HttpDownloadFile(
                                             $"http://resharper-plugins.jetbrains.com/dotnet/api/v2/curated-feeds/Wave_v{wave}.0/Packages(Id='{x.Key}',Version='{x.Value}')/Download",
                                             Path.Combine(shadowDirectory, $"{x.Key}.nupkg")));

            toolSettings = toolSettings.SetProcessToolPath(Path.Combine(shadowDirectory, Path.GetFileName(toolSettings.ProcessToolPath)));
        }
Ejemplo n.º 10
0
        private static void PreProcess(ref InspectCodeSettings toolSettings)
        {
            var installedPlugins = GetInstalledPlugins();

            if (installedPlugins.Count == 0 && toolSettings.Plugins.Count == 0)
            {
                return;
            }

            var shadowDirectory = GetShadowDirectory(toolSettings, installedPlugins);

            FileSystemTasks.CopyDirectoryRecursively(
                Path.GetDirectoryName(toolSettings.ToolPath).NotNull(),
                shadowDirectory,
                DirectoryExistsPolicy.Merge,
                FileExistsPolicy.OverwriteIfNewer);

            installedPlugins.Select(x => x.FileName)
            .ForEach(x => File.Copy(x, Path.Combine(shadowDirectory, Path.GetFileName(x).NotNull()), overwrite: true));

            toolSettings.Plugins.ForEach(x => HttpTasks.HttpDownloadFile(
                                             $"http://resharper-plugins.jetbrains.com/dotnet/api/v2/Packages(Id='{x.Key}',Version='{x.Value}')/Download",
                                             Path.Combine(shadowDirectory, $"{x.Key}.nupkg")));
        }
Ejemplo n.º 11
0
    const string LuaVersion        = "5.3.5";   // From Delivr

    void DownloadToolsWindows()
    {
        Logger.Info("Downloading FFmpeg.");
        string ffmpegVersion =
            HttpTasks.HttpDownloadString(
                "https://www.gyan.dev/ffmpeg/builds/release-version");

        Logger.Info($"Downloading FFmpeg {ffmpegVersion}.");
        HttpTasks.HttpDownloadFile(
            $"https://github.com/GyanD/codexffmpeg/releases/download/{ffmpegVersion}/ffmpeg-{ffmpegVersion}-full_build.zip",
            ToolsTempDirectory / "ffmpeg.zip");

        AbsolutePath ffmpegExtractTempPath = ToolsTempDirectory / "ffmpeg";

        Logger.Info("Extracting FFmpeg.");
        CompressionTasks.UncompressZip(
            ToolsTempDirectory / "ffmpeg.zip",
            ffmpegExtractTempPath);

        ForceCopyDirectoryRecursively(
            ffmpegExtractTempPath / $"ffmpeg-{ffmpegVersion}-full_build" / "bin",
            ToolsDirectory);

        Logger.Info("Downloading x264.");
        HttpTasks.HttpDownloadFile(
            $"https://artifacts.videolan.org/x264/release-win64/x264-{X264Version}.exe",
            ToolsDirectory / "x264.exe");

        Logger.Info("Downloading x265.");
        new[]
        {
            8,
            10,
            12
        }.ForEach(x =>
        {
            HttpTasks.HttpDownloadFile(
                $"https://builds.x265.eu/x265-64bit-{x}bit-latest.exe",
                ToolsDirectory / $"x265-64bit-{x}bit-latest.exe");
        });

        Logger.Info($"Downloading PowerShell v{PowerShellVersion}.");
        HttpTasks.HttpDownloadFile(
            $"https://github.com/PowerShell/PowerShell/releases/download/v{PowerShellVersion}/PowerShell-{PowerShellVersion}-win-x64.zip",
            ToolsTempDirectory / "pwsh.zip");

        Logger.Info("Extracting PowerShell.");
        CompressionTasks.UncompressZip(
            ToolsTempDirectory / "pwsh.zip",
            ToolsDirectory);

        Logger.Info("Downloading Node.js.");
        HttpTasks.HttpDownloadFile(
            $"https://nodejs.org/dist/v{NodejsVersion}/node-v{NodejsVersion}-win-x64.zip",
            ToolsTempDirectory / "node.zip");

        AbsolutePath nodeExtractTempPath = ToolsTempDirectory / "node";

        Logger.Info("Extracting Node.js.");
        CompressionTasks.UncompressZip(
            ToolsTempDirectory / "node.zip",
            nodeExtractTempPath);

        ForceCopyDirectoryRecursively(
            nodeExtractTempPath / $"node-v{NodejsVersion}-win-x64",
            ToolsDirectory);

        Logger.Info("Downloading Python.");
        HttpTasks.HttpDownloadFile(
            $"https://www.python.org/ftp/python/{PythonVersion}/python-{PythonVersion}-embed-amd64.zip",
            ToolsTempDirectory / "python.zip");

        Logger.Info("Extracting Python.");
        CompressionTasks.UncompressZip(
            ToolsTempDirectory / "python.zip",
            ToolsDirectory);

        Logger.Info("Downloading Lua.");
        HttpTasks.HttpDownloadFile(
            $"https://raw.githubusercontent.com/Afanyiyu/Delivr/master/lua/lua-{LuaVersion}-win.zip",
            ToolsTempDirectory / "lua.zip");

        Logger.Info("Extracting Lua.");
        CompressionTasks.UncompressZip(
            ToolsTempDirectory / "lua.zip",
            ToolsDirectory);

        Logger.Info("Downloading json.lua.");
        HttpTasks.HttpDownloadFile(
            "https://raw.githubusercontent.com/Afanyiyu/Delivr/master/lua/json.lua.zip",
            ToolsTempDirectory / "json.lua.zip");

        Logger.Info("Extracting json.lua.");
        CompressionTasks.UncompressZip(
            ToolsTempDirectory / "json.lua.zip",
            ToolsDirectory);

        Logger.Info("Downloading 7za.");
        HttpTasks.HttpDownloadFile(
            "https://raw.githubusercontent.com/develar/7zip-bin/master/win/x64/7za.exe",
            ToolsTempDirectory / "7za.exe");

        Logger.Info("Moving 7za.");
        CopyFileToDirectory(
            ToolsTempDirectory / "7za.exe",
            ToolsDirectory);

        Logger.Info("Downloading HwEnc.");
        HttpTasks.HttpDownloadFile(
            "https://raw.githubusercontent.com/Afanyiyu/Delivr/master/rmbox/hwenc.zip",
            ToolsTempDirectory / "hwenc.zip");

        Logger.Info("Extracting HwEnc.");
        CompressionTasks.UncompressZip(
            ToolsTempDirectory / "hwenc.zip",
            ToolsDirectory);

        Logger.Info("Downloading QAAC.");
        HttpTasks.HttpDownloadFile(
            "https://raw.githubusercontent.com/Afanyiyu/Delivr/master/rmbox/qaac.zip",
            ToolsTempDirectory / "qaac.zip");

        Logger.Info("Extracting QAAC.");
        CompressionTasks.UncompressZip(
            ToolsTempDirectory / "qaac.zip",
            ToolsDirectory);

        Logger.Info("Downloading VapourSynth.");
        HttpTasks.HttpDownloadFile(
            "https://raw.githubusercontent.com/Afanyiyu/Delivr/master/rmbox/vsfm.zip",
            ToolsTempDirectory / "vsfm.zip");

        Logger.Info("Extracting VapourSynth.");
        CompressionTasks.UncompressZip(
            ToolsTempDirectory / "vsfm.zip",
            ToolsDirectory);
    }
Ejemplo n.º 12
0
    void DownloadToolsLinux()
    {
        Logger.Info("Downloading FFmpeg.");
        HttpTasks.HttpDownloadFile(
            "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz",
            ToolsTempDirectory / "ffmpeg.tar.xz");

        // You need to extract "ffmpeg.tar.xz" yourself.
        CopyFileToDirectory(
            ToolsTempDirectory / "ffmpeg.tar.xz",
            ToolsDirectory);

        Logger.Info("Downloading x264.");
        HttpTasks.HttpDownloadFile(
            $"https://artifacts.videolan.org/x264/release-debian-amd64/x264-{X264Version}",
            ToolsDirectory / "x264.exe");

        Logger.Info($"Downloading PowerShell v{PowerShellVersion}.");
        HttpTasks.HttpDownloadFile(
            $"https://github.com/PowerShell/PowerShell/releases/download/v{PowerShellVersion}/PowerShell-{PowerShellVersion}-linux-x64.tar.gz",
            ToolsTempDirectory / "pwsh.tar.gz");

        Logger.Info("Extracting PowerShell.");
        CompressionTasks.UncompressTarGZip(
            ToolsTempDirectory / "pwsh.tar.gz",
            ToolsDirectory);

        Logger.Info("Downloading Node.js.");
        HttpTasks.HttpDownloadFile(
            $"https://nodejs.org/dist/v{NodejsVersion}/node-v{NodejsVersion}-linux-x64.tar.xz",
            ToolsTempDirectory / "node.tar.xz");

        // You need to extract "node.tar.xz" yourself.
        CopyFileToDirectory(
            ToolsTempDirectory / "node.tar.xz",
            ToolsDirectory);

        // You need to compile Python yourself.

        Logger.Info("Downloading Lua.");
        HttpTasks.HttpDownloadFile(
            $"https://raw.githubusercontent.com/Afanyiyu/Delivr/master/lua/lua-{LuaVersion}-linux.zip",
            ToolsTempDirectory / "lua.zip");

        Logger.Info("Extracting Lua.");
        CompressionTasks.UncompressZip(
            ToolsTempDirectory / "lua.zip",
            ToolsDirectory);

        Logger.Info("Downloading json.lua.");
        HttpTasks.HttpDownloadFile(
            "https://raw.githubusercontent.com/Afanyiyu/Delivr/master/lua/json.lua.zip",
            ToolsTempDirectory / "json.lua.zip");

        Logger.Info("Extracting json.lua.");
        CompressionTasks.UncompressZip(
            ToolsTempDirectory / "json.lua.zip",
            ToolsDirectory);

        Logger.Info("Downloading 7za.");
        HttpTasks.HttpDownloadFile(
            "https://raw.githubusercontent.com/develar/7zip-bin/master/linux/x64/7za",
            ToolsTempDirectory / "7za");

        Logger.Info("Moving 7za.");
        CopyFileToDirectory(
            ToolsTempDirectory / "7za",
            ToolsDirectory);
    }
Ejemplo n.º 13
0
    void DownloadToolsMacos()
    {
        Logger.Info("Downloading FFmpeg.");

        new[]
        {
            "ffmpeg",
            "ffprobe",
            "ffplay",
            "ffserver"
        }.ForEach(x =>
        {
            Logger.Info($"Downloading {x}.");
            HttpTasks.HttpDownloadFile(
                $"https://evermeet.cx/ffmpeg/getrelease/{x}/zip",
                ToolsTempDirectory / $"{x}.zip");

            Logger.Info($"Extracting {x}.");
            CompressionTasks.UncompressZip(
                ToolsTempDirectory / $"{x}.zip",
                ToolsDirectory);
        });

        Logger.Info("Downloading x264.");
        HttpTasks.HttpDownloadFile(
            $"https://artifacts.videolan.org/x264/release-macos-x86_64/x264-{X264Version}",
            ToolsDirectory / "x264.exe");

        Logger.Info($"Downloading PowerShell v{PowerShellVersion}.");
        HttpTasks.HttpDownloadFile(
            $"https://github.com/PowerShell/PowerShell/releases/download/v{PowerShellVersion}/PowerShell-{PowerShellVersion}-osx-x64.tar.gz",
            ToolsTempDirectory / "pwsh.tar.gz");

        Logger.Info("Extracting PowerShell.");
        CompressionTasks.UncompressTarGZip(
            ToolsTempDirectory / "pwsh.tar.gz",
            ToolsDirectory);

        Logger.Info("Downloading Node.js.");
        HttpTasks.HttpDownloadFile(
            $"https://nodejs.org/dist/v{NodejsVersion}/node-v{NodejsVersion}-darwin-x64.tar.gz",
            ToolsTempDirectory / "node.tar.gz");

        AbsolutePath nodeExtractTempPath = ToolsTempDirectory / "node";

        Logger.Info("Extracting Node.js.");
        CompressionTasks.UncompressTarGZip(
            ToolsTempDirectory / "node.tar.gz",
            nodeExtractTempPath);

        // You need to manually install npm.
        ForceCopyDirectoryRecursively(
            nodeExtractTempPath / $"node-v{NodejsVersion}-darwin-x64" / "bin",
            ToolsDirectory);

        // You need to compile Python yourself.

        Logger.Info("Downloading Lua.");
        HttpTasks.HttpDownloadFile(
            $"https://raw.githubusercontent.com/Afanyiyu/Delivr/master/lua/lua-{LuaVersion}-osx.zip",
            ToolsTempDirectory / "lua.zip");

        Logger.Info("Extracting Lua.");
        CompressionTasks.UncompressZip(
            ToolsTempDirectory / "lua.zip",
            ToolsDirectory);

        Logger.Info("Downloading json.lua.");
        HttpTasks.HttpDownloadFile(
            "https://raw.githubusercontent.com/Afanyiyu/Delivr/master/lua/json.lua.zip",
            ToolsTempDirectory / "json.lua.zip");

        Logger.Info("Extracting json.lua.");
        CompressionTasks.UncompressZip(
            ToolsTempDirectory / "json.lua.zip",
            ToolsDirectory);

        Logger.Info("Downloading 7za.");
        HttpTasks.HttpDownloadFile(
            "https://raw.githubusercontent.com/develar/7zip-bin/master/mac/x64/7za",
            ToolsTempDirectory / "7za");

        Logger.Info("Moving 7za.");
        CopyFileToDirectory(
            ToolsTempDirectory / "7za",
            ToolsDirectory);
    }