예제 #1
0
        private static string?FindGazelle(Runfiles runfiles)
        {
            // are we released?
            var    artifactsFolder = runfiles.Rlocation($"rules_msbuild/.azpipelines/artifacts");
            string?gazellePath     = null;

            // if we're in nuget, runfiles will be directory-based, and this will work just fine on windows
            if (Directory.Exists(artifactsFolder))
            {
                var subPath = Util.GetGazellePath();
                gazellePath = Path.Combine(artifactsFolder, subPath);
            }
            else
            {
                string suffix = "";
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    suffix = ".exe";
                }
                gazellePath =
                    runfiles.Rlocation($"rules_msbuild/gazelle/dotnet/gazelle-dotnet_/gazelle-dotnet{suffix}");
            }

            if (gazellePath == null || !File.Exists(gazellePath))
            {
                Console.Error.WriteLine(
                    $"Failed to locate gazelle-dotnet binary at path {gazellePath}, please file an issue at github.com/samhowes/rules_msbuild");
                return(null);
            }

            return(gazellePath);
        }
예제 #2
0
        private void AssertRlocationArg(Runfiles runfiles, string path, string error)
        {
            var e =
                AssertThrows <ArgumentException>(() => runfiles.Rlocation(path));

            if (error != null)
            {
                e.Message.Should().Contain(error);
            }
        }
예제 #3
0
        public static string UpdateWorkspaceTemplate(Runfiles runfiles, string tarPath, string url)
        {
            var workspaceTemplate =
                File.ReadAllText(runfiles.Rlocation("rules_msbuild/dotnet/tools/Bzl/WORKSPACE.tpl"));
            var sha256 = File.ReadAllText(tarPath + ".sha256");

            var indexMatch = Regex.Match(workspaceTemplate, @"http_archive\(.*\s+name = ""rules_msbuild"",",
                                         RegexOptions.IgnoreCase | RegexOptions.Singleline);

            var index   = (indexMatch.Index + indexMatch.Length);
            var section = workspaceTemplate[index..];