public async Task <int> RunAsync(PublishArguments args) { var inputPath = PathHelper.ResolvePath(args.InputFile); var inputUri = PathHelper.FilePathToFileUrl(inputPath); var configuration = this.configurationManager.GetConfiguration(inputUri); var moduleReference = ValidateReference(args.TargetModuleReference, configuration); if (PathHelper.HasArmTemplateLikeExtension(inputUri)) { // Publishing an ARM template file. using var armTemplateStream = this.fileSystem.FileStream.Create(inputPath, FileMode.Open, FileAccess.Read); await this.PublishModuleAsync(configuration, moduleReference, armTemplateStream); return(0); } var compilation = await compilationService.CompileAsync(inputPath, args.NoRestore); if (diagnosticLogger.ErrorCount > 0) { // can't publish if we can't compile return(1); } var stream = new MemoryStream(); compilationWriter.ToStream(compilation, stream); stream.Position = 0; await this.PublishModuleAsync(compilation.Configuration, moduleReference, stream); return(0); }
private static async Task <int> Publish(PublishArguments args) { var pack = await LoadPack(args.PackDirectory, true); if (pack == null) { return(1); } return(await pack.Publish() ? 0 : 1); }
public async Task <int> RunAsync(PublishArguments args) { var moduleReference = ValidateReference(args.TargetModuleReference); var inputPath = PathHelper.ResolvePath(args.InputFile); var compilation = await compilationService.CompileAsync(inputPath, args.NoRestore); if (diagnosticLogger.ErrorCount > 0) { // can't publish if we can't compile return(1); } var stream = new MemoryStream(); compilationWriter.ToStream(compilation, stream); stream.Position = 0; await this.moduleDispatcher.PublishModule(compilation.Configuration, moduleReference, stream); return(0); }