Example #1
0
		static int Main(string[] args)
		{
			Constants.SetApplicationName("Appcast");
#if TESTING
			var testargs = new List<string>
			               	{
			               		"-i",
			               		@"C:\code\tubeCentric.root\amazon tools.root\Amazon SES\TenCentMail.Setup\bin\Release\en-us\TenCentMail.msi",
			               		
								"-o",
			               		@"C:\Users\curtis\Documents\CarverLab\TenCentMail\appcast2.xml",
			               		
								"-r",
			               		@"C:\Users\curtis\Documents\CarverLab\TenCentMail\releasenotes.0.2.txt",
			               		
								"-k",
			               		@"C:\Users\curtis\Documents\CarverLab\TenCentMail\NetSparkle_DSA.priv",
			               	};
			args = testargs.ToArray();
#endif

			var config = new Config(args);

			if (args.Length == 0)
			{
				config.ShowHelp();
				return 1;
			}
			try
			{
				config.Parse();
			}
			catch (Exception exception)
			{
				System.Console.WriteLine(exception);
				return 200;
			}

			config.Logo(System.Console.Error);

			var bootstrapper = new SimpleBootstrapper();
			bootstrapper.Run();
			var appcast = new AppcastViewModel();

			string did;
			if (config.OutputPath.Exists && !config.Overwrite)
			{
				appcast.Load(config.OutputPath.FullName);
				did = "Updated";
			}
			else
			{
				appcast.AppcastBaseAddress = config.AppcastBaseAddress;
				appcast.AppcastName = config.AppcastName;
				appcast.ApplicationName = config.ApplicationName;
				appcast.Description = config.Description;
				appcast.Language = config.Language;
				appcast.OutputPath = config.OutputPath;
				var link = new Uri(config.AppcastBaseAddress);
				appcast.AppcastLink = string.Format("{0}/{1}/{2}", link.AbsolutePath, appcast.ApplicationName, appcast.AppcastName);
				did = "Created";
			}

			string releaseNotesPath = null;
			if (config.ReleaseNotesPath != null)
			{
				releaseNotesPath = config.ReleaseNotesPath.FullName;
			}
			if (string.IsNullOrEmpty(appcast.AppcastName) && !string.IsNullOrEmpty(config.AppcastName))
			{
				appcast.AppcastName = config.AppcastName;
			}
			if (string.IsNullOrEmpty(appcast.ApplicationName) && !string.IsNullOrEmpty(config.ApplicationName))
			{
				appcast.ApplicationName = config.ApplicationName;
			}
			if (string.IsNullOrEmpty(appcast.AppcastBaseAddress) && !string.IsNullOrEmpty(config.AppcastBaseAddress))
			{
				appcast.AppcastBaseAddress = config.AppcastBaseAddress;
			}
			var item = new AppcastItemViewModel(appcast, config.InputPath.FullName, releaseNotesPath, config.PrivateKeyPath.FullName);
			appcast.AppcastItems.Add(item);

			appcast.Save(appcast.OutputPath.FullName);
			//Environment.SetEnvironmentVariable("AppcastAppVersion", item.Version.ToString(3), EnvironmentVariableTarget.Machine);
			File.WriteAllText("appcastappversion.txt", item.Version.ToString(3));

			System.Console.WriteLine(@"{0} {1}", did, appcast.OutputPath);
			return 0;
		}