Esempio n. 1
0
        private async Task <int> OnExecuteAsync(CommandLineApplication app,
                                                CancellationToken cancellationToken = default)
        {
            PackingParameters packingParameters = null;
            string            ursaConfPath      = null;

            if (!File.Exists(ConfigurationPath) && !Directory.Exists(ConfigurationPath))
            {
                throw new FileNotFoundException(DefaultUrsaConfFileName);
            }

            var fileAttributes = File.GetAttributes(ConfigurationPath);

            if (fileAttributes.HasFlag(FileAttributes.Directory))
            {
                ursaConfPath = Directory.EnumerateFiles(ConfigurationPath)
                               .FirstOrDefault(path => path.EndsWith(DefaultUrsaConfFileName));
            }
            else
            {
                ursaConfPath = ConfigurationPath;
            }

            if (ursaConfPath == null)
            {
                throw new FileNotFoundException(DefaultUrsaConfFileName);
            }

            using (var streamReader = File.OpenText(ConfigurationPath))
            {
                packingParameters = new DeserializerBuilder()
                                    .WithNamingConvention(UnderscoredNamingConvention.Instance)
                                    .Build()
                                    .Deserialize <PackingParameters>(streamReader);

                packingParameters.Initialize(NugetApiKey);
            }

            return(await new UrsaApplication(app)
                   .RunAsync(packingParameters, cancellationToken));
        }
Esempio n. 2
0
        public async Task <int> RunAsync(PackingParameters parameters, CancellationToken cancellationToken)
        {
            PackingParameters = parameters;

            PrepareEnvironment();

            var codeFactory = new CodeFactory(new ITemplateCodeProvider[]
            {
                new NSwagTemplateCodeProvider(),
                new UrsaTemplateCodeProvider()
            }, parameters);
            var code = await codeFactory.CreateCodeAsync(cancellationToken);

            await new DotnetProjectBuilder(code)
            .BuildAsync(cancellationToken);

            var nugetWorker = new NugetPackageWorker();
            await nugetWorker.PackAsync(cancellationToken);

            await nugetWorker.PushAsync(cancellationToken);

            return(0);
        }
Esempio n. 3
0
 public NugetPackageWorker()
 {
     _packingParameters = UrsaApplication.PackingParameters;
 }
Esempio n. 4
0
 public DotnetProjectBuilder(string code)
 {
     _packingParameters = UrsaApplication.PackingParameters;
     _code = code;
 }