コード例 #1
0
 public ProjectBazelManipulator(ProjectBazelConfig prjConfig, string mainFile, bool skipSha256) : base(Path.Combine(prjConfig.RootPath, "packages"))
 {
     ProjectConfig  = prjConfig;
     _mainFile      = mainFile;
     _skipSha256    = skipSha256;
     JsonConfigPath = Path.Combine(ProjectConfig.RootPath, ProjectConfig.Nuget2BazelConfigName);
     WorkspacePath  = Path.Combine(ProjectConfig.RootPath, ProjectConfig.BazelFileName);
 }
コード例 #2
0
ファイル: SyncCommand.cs プロジェクト: samhowes/rules_dotnet
 private async Task Add(ILogger logger, string package, string version, ProjectBazelConfig prjConfig)
 {
     try
     {
         var cmd = new AddCommand();
         await cmd.Do(prjConfig, package, version, null, true, false, null);
     }
     catch (Exception ex)
     {
         logger.LogError($"Exception on adding {package}:{version}");
         logger.LogError(ex.ToString());
     }
 }
コード例 #3
0
ファイル: SyncCommand.cs プロジェクト: samhowes/rules_dotnet
 private async Task Delete(ILogger logger, string package, ProjectBazelConfig prjConfig)
 {
     try
     {
         var cmd = new DeleteCommand();
         await cmd.Do(prjConfig, package);
     }
     catch (Exception ex)
     {
         logger.LogError($"Exception on deleting {package}");
         logger.LogError(ex.ToString());
     }
 }
コード例 #4
0
        public SyncT()
        {
            var root = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            Directory.CreateDirectory(root);
            _prjConfig = new ProjectBazelConfig(root);

            // Nuget libraries require HOME ans some other variables set
            Environment.SetEnvironmentVariable("HOME", root);
            Environment.SetEnvironmentVariable("DOTNET_CLI_HOME", root);
            Environment.SetEnvironmentVariable("APPDATA", Path.Combine(root, ".nuget"));
            Environment.SetEnvironmentVariable("PROGRAMFILES", Path.Combine(root, ".nuget"));
            Environment.SetEnvironmentVariable("LOCALAPPDATA", Path.Combine(root, ".local", "share"));
        }
コード例 #5
0
        public Task Do(ProjectBazelConfig prjConfig, string package, string version, string mainFile, bool skipSha256, bool lowest, string variable)
        {
            var project = new ProjectBazelManipulator(prjConfig, mainFile, skipSha256, variable);

            if (prjConfig.ProjectFiles != null)
            {
                var projectFileParser = new ProjectFileParser(prjConfig);
                var packages          = projectFileParser.GetNugetPackages();

                var nugetTasks = packages.Select(p => DoWithProject(prjConfig.NugetSource, p.Name, p.Version, project, lowest)).ToArray();

                return(Task.WhenAll(nugetTasks));
            }

            return(DoWithProject(prjConfig.NugetSource, package, version, project, lowest));
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: wbiker/rules_dotnet
        static void Main(string[] args)
        {
            var parsed = Parser.Default.ParseArguments <AddVerb, DeleteVerb, SyncVerb, UpdateVerb, RulesVerb>(args);
            var result = parsed.MapResult <AddVerb, DeleteVerb, SyncVerb, UpdateVerb, RulesVerb, int>(
                (AddVerb opts) =>
            {
                var prjConfig = new ProjectBazelConfig(opts);
                var res       = new AddCommand().Do(prjConfig, opts.Package, opts.Version, opts.MainFile, opts.SkipSha256, opts.Lowest, opts.Variable);
                res.Wait();
                return(0);
            },
                (DeleteVerb opts) =>
            {
                var prjConfig = new ProjectBazelConfig(opts);
                var res       = new DeleteCommand().Do(prjConfig, opts.Package);
                res.Wait();
                return(0);
            },
                (SyncVerb opts) =>
            {
                var prjConfig = new ProjectBazelConfig(opts);
                var res       = new SyncCommand().Do(prjConfig);
                res.Wait();
                return(0);
            },
                (UpdateVerb opts) =>
            {
                var prjConfig = new ProjectBazelConfig(opts);
                var res       = new UpdateCommand().Do(prjConfig, opts.Package, opts.Version, opts.MainFile, opts.SkipSha256, opts.Lowest, opts.Variable);
                res.Wait();
                return(0);
            },
                (RulesVerb opts) =>
            {
                var res = new RulesCommand().Do(opts.Path);
                res.Wait();
                return(0);
            },
                errs =>
            {
                HelpText.AutoBuild(parsed);
                return(-1);
            }
                );

            Environment.Exit(result);
        }
コード例 #7
0
ファイル: SyncCommand.cs プロジェクト: samhowes/rules_dotnet
        public async Task Do(ProjectBazelConfig prjConfig)
        {
            var logger = new Logger();

            var packagesJsonPath = Path.Combine(prjConfig.RootPath, prjConfig.Nuget2BazelConfigName);
            var s = await File.ReadAllTextAsync(packagesJsonPath);

            var packagesJson = JsonConvert.DeserializeObject <PackagesJson>(s);

            foreach (var d in packagesJson.dependencies)
            {
                await Delete(logger, d.Key, prjConfig);
            }

            foreach (var d in packagesJson.dependencies)
            {
                await Add(logger, d.Key, d.Value, prjConfig);
            }
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: purkhusid/rules_dotnet
        private static async Task Main(string[] args)
        {
            var parsed = Parser.Default.ParseArguments <AddVerb, DeleteVerb, SyncVerb, UpdateVerb, RulesVerb>(args);
            var result = await parsed.MapResult <AddVerb, DeleteVerb, SyncVerb, UpdateVerb, RulesVerb, Task <int> >(
                async (AddVerb opts) =>
            {
                var prjConfig = new ProjectBazelConfig(opts);
                await new AddCommand().Do(prjConfig, opts.Package, opts.Version, opts.MainFile, opts.SkipSha256, opts.Lowest, opts.CustomTargetName);
                return(0);
            },
                async (DeleteVerb opts) =>
            {
                var prjConfig = new ProjectBazelConfig(opts);
                await new DeleteCommand().Do(prjConfig, opts.Package);
                return(0);
            },
                async (SyncVerb opts) =>
            {
                var prjConfig = new ProjectBazelConfig(opts);
                await new SyncCommand().Do(prjConfig);
                return(0);
            },
                async (UpdateVerb opts) =>
            {
                var prjConfig = new ProjectBazelConfig(opts);
                await new UpdateCommand().Do(prjConfig, opts.Package, opts.Version, opts.MainFile, opts.SkipSha256, opts.Lowest, opts.CustomTargetName);
                return(0);
            },
                async (RulesVerb opts) =>
            {
                await new RulesCommand().Do(opts.Path);
                return(0);
            },
                errs =>
            {
                HelpText.AutoBuild(parsed);
                return(Task.FromResult(-1));
            }
                );

            Environment.Exit(result);
        }
コード例 #9
0
ファイル: DeleteCommand.cs プロジェクト: ztl8702/rules_dotnet
        public async Task Do(ProjectBazelConfig prjConfig, string package)
        {
            var providers = new List <Lazy <INuGetResourceProvider> >();

            providers.AddRange(Repository.Provider.GetCoreV3());  // Add v3 API support

            var settings = Settings.LoadDefaultSettings(prjConfig.RootPath, null, new MachineWideSettings());
            var project  = new ProjectBazelManipulator(prjConfig, null, false, null);
            var sourceRepositoryProvider = new SourceRepositoryProvider(settings, providers);
            var solutionManager          = new BazelSolutionManager(project, prjConfig.RootPath);
            var deleteManager            = new DeleteOnRestart();
            var packageManager           = new NuGetPackageManager(sourceRepositoryProvider, settings, solutionManager, deleteManager)
            {
                PackagesFolderNuGetProject = project,
            };

            var projectContext   = new ProjectContext(settings);
            var uninstallContext = new UninstallationContext(true, true);

            await packageManager.UninstallPackageAsync(packageManager.PackagesFolderNuGetProject,
                                                       package, uninstallContext, projectContext,
                                                       CancellationToken.None);
        }
コード例 #10
0
ファイル: RemotionLinqT.cs プロジェクト: ztl8702/rules_dotnet
 public TestProject(ProjectBazelConfig prjConfig) : base(prjConfig, null, false, null)
 {
 }
コード例 #11
0
        public Task Do(ProjectBazelConfig prjConfig, string package, string version, string mainFile, bool skipSha256, bool lowest, string variable)
        {
            var project = new ProjectBazelManipulator(prjConfig, mainFile, skipSha256, variable);

            return(DoWithProject(package, version, project, lowest));
        }
コード例 #12
0
 public ProjectFileParser(ProjectBazelConfig prjConfig)
 {
     this.prjConfig = prjConfig;
 }