2012-08-23 14:46:53 +00:00
|
|
|
#region Using Statements
|
2012-08-11 13:06:29 +00:00
|
|
|
using System;
|
2012-09-01 15:09:10 +00:00
|
|
|
using System.Collections.Generic;
|
2012-08-11 13:06:29 +00:00
|
|
|
using System.IO;
|
2012-11-17 17:52:49 +00:00
|
|
|
using System.Windows.Forms;
|
|
|
|
using ProjectConverter.GUI;
|
2012-08-11 13:06:29 +00:00
|
|
|
using ProjectConverter.Platforms;
|
2012-08-23 14:46:53 +00:00
|
|
|
|
|
|
|
#endregion
|
2012-08-11 13:06:29 +00:00
|
|
|
|
|
|
|
// This file is part of the ANX.Framework created by the
|
|
|
|
// "ANX.Framework developer group" and released under the Ms-PL license.
|
|
|
|
// For details see: http://anxframework.codeplex.com/license
|
|
|
|
|
|
|
|
namespace ProjectConverter
|
|
|
|
{
|
|
|
|
static class Program
|
|
|
|
{
|
2012-11-17 17:52:49 +00:00
|
|
|
public static readonly Converter[] Converters = new Converter[]
|
2012-09-01 15:09:10 +00:00
|
|
|
{
|
|
|
|
new LinuxConverter(),
|
|
|
|
new MetroConverter(),
|
2012-10-23 07:37:08 +00:00
|
|
|
new PsVitaConverter(),
|
|
|
|
new AnxConverter(),
|
|
|
|
new XnaConverter(),
|
2012-10-27 06:47:35 +00:00
|
|
|
new XnaContentProjectConverter(),
|
|
|
|
new AnxContentProjectConverter(),
|
2012-09-01 15:09:10 +00:00
|
|
|
};
|
2012-08-23 14:46:53 +00:00
|
|
|
|
2012-10-23 09:23:41 +00:00
|
|
|
private static readonly List<string> switches = new List<string>();
|
|
|
|
private static readonly Dictionary<string, string> keyValueParameters = new Dictionary<string, string>();
|
|
|
|
private static readonly List<string> files = new List<string>();
|
|
|
|
|
2012-08-11 13:06:29 +00:00
|
|
|
[STAThread]
|
|
|
|
static void Main(string[] args)
|
|
|
|
{
|
2012-08-23 14:46:53 +00:00
|
|
|
//
|
|
|
|
// To restore "old" behaviour use:
|
|
|
|
// ProjectConverter /linux /psvita /windowsmetro ../../ANX.Framework.sln
|
2012-08-30 09:28:02 +00:00
|
|
|
//
|
2012-08-23 14:46:53 +00:00
|
|
|
|
2012-10-01 12:17:53 +00:00
|
|
|
Directory.SetCurrentDirectory(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location));
|
|
|
|
|
2012-11-17 17:52:49 +00:00
|
|
|
if (args.Length == 0)
|
|
|
|
{
|
|
|
|
using (var gui = new MainWindow())
|
|
|
|
{
|
|
|
|
Application.EnableVisualStyles();
|
|
|
|
gui.ShowDialog();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-09-01 15:09:10 +00:00
|
|
|
foreach (string arg in args)
|
|
|
|
{
|
2012-10-27 06:47:35 +00:00
|
|
|
string larg = arg.Trim();
|
|
|
|
if (larg.StartsWith("/") || larg.StartsWith("-"))
|
2012-09-01 15:09:10 +00:00
|
|
|
{
|
2012-10-27 06:47:35 +00:00
|
|
|
if (larg.Contains("="))
|
2012-10-23 09:23:41 +00:00
|
|
|
{
|
2012-10-27 06:47:35 +00:00
|
|
|
string[] parts = larg.Split('=');
|
2012-10-23 09:23:41 +00:00
|
|
|
keyValueParameters[parts[0].Trim().ToLowerInvariant()] = parts[1].Trim().ToLowerInvariant();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-10-27 06:47:35 +00:00
|
|
|
switches.Add(larg.Substring(1).Trim().ToLowerInvariant());
|
2012-10-23 09:23:41 +00:00
|
|
|
}
|
2012-09-01 15:09:10 +00:00
|
|
|
}
|
2012-10-27 06:47:35 +00:00
|
|
|
else if (File.Exists(larg))
|
2012-10-23 09:23:41 +00:00
|
|
|
{
|
2012-10-27 06:47:35 +00:00
|
|
|
files.Add(larg);
|
2012-10-23 09:23:41 +00:00
|
|
|
}
|
2012-09-01 15:09:10 +00:00
|
|
|
}
|
2012-08-11 13:06:29 +00:00
|
|
|
|
2012-08-23 14:46:53 +00:00
|
|
|
foreach (string file in files)
|
|
|
|
{
|
|
|
|
string fileExt = Path.GetExtension(file).ToLowerInvariant();
|
2012-09-29 08:57:24 +00:00
|
|
|
foreach (Converter converter in Converters)
|
2012-08-23 14:46:53 +00:00
|
|
|
{
|
2012-10-23 07:37:08 +00:00
|
|
|
if (switches.Contains(converter.Name.ToLowerInvariant()))
|
2012-08-23 14:46:53 +00:00
|
|
|
{
|
|
|
|
switch (fileExt)
|
|
|
|
{
|
|
|
|
case ".sln":
|
2012-10-23 09:23:41 +00:00
|
|
|
converter.ConvertAllProjects(file, TryGetDestinationPath());
|
2012-08-23 14:46:53 +00:00
|
|
|
break;
|
2012-08-23 21:11:44 +00:00
|
|
|
case ".csproj":
|
2012-10-27 06:47:35 +00:00
|
|
|
case ".contentproj":
|
2012-10-23 09:23:41 +00:00
|
|
|
converter.ConvertProject(file, TryGetDestinationPath());
|
2012-08-23 21:11:44 +00:00
|
|
|
break;
|
2012-10-27 06:47:35 +00:00
|
|
|
case ".cproj":
|
|
|
|
converter.ConvertAnxContentProject(file, TryGetDestinationPath());
|
|
|
|
break;
|
2012-08-23 14:46:53 +00:00
|
|
|
default:
|
|
|
|
throw new NotImplementedException("unsupported file type '" + fileExt + "'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-11 13:06:29 +00:00
|
|
|
}
|
2012-10-23 09:23:41 +00:00
|
|
|
|
|
|
|
private static string TryGetDestinationPath()
|
|
|
|
{
|
|
|
|
foreach (KeyValuePair<string, string> kvp in keyValueParameters)
|
|
|
|
{
|
|
|
|
if (string.Equals(kvp.Key, "/O", StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
{
|
2012-10-27 06:47:35 +00:00
|
|
|
return Path.GetDirectoryName(kvp.Value);
|
2012-10-23 09:23:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return string.Empty;
|
|
|
|
}
|
2012-08-11 13:06:29 +00:00
|
|
|
}
|
|
|
|
}
|