2012-08-11 13:06:29 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
|
|
|
|
|
namespace ProjectConverter.Platforms
|
|
|
|
|
{
|
|
|
|
|
public class MetroConverter : Converter
|
|
|
|
|
{
|
2012-08-12 21:43:28 +00:00
|
|
|
|
private bool isCurrentProjectExecutable;
|
|
|
|
|
|
2012-08-11 13:06:29 +00:00
|
|
|
|
public override string Postfix
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return "WindowsMetro";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region ConvertImport
|
|
|
|
|
protected override void ConvertImport(XElement element, XAttribute projectAttribute)
|
|
|
|
|
{
|
|
|
|
|
if (projectAttribute != null)
|
|
|
|
|
{
|
|
|
|
|
if (projectAttribute.Value.EndsWith("Microsoft.CSharp.targets"))
|
|
|
|
|
{
|
|
|
|
|
projectAttribute.Value =
|
|
|
|
|
@"$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\" +
|
|
|
|
|
@"v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets";
|
|
|
|
|
}
|
|
|
|
|
else if (projectAttribute.Value.EndsWith(XnaGameStudioTarget) ||
|
|
|
|
|
projectAttribute.Value.EndsWith(XnaPipelineExtensionTarget))
|
|
|
|
|
{
|
|
|
|
|
element.Remove();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
2012-08-12 20:00:19 +00:00
|
|
|
|
|
2012-08-11 13:06:29 +00:00
|
|
|
|
#region ConvertMainPropertyGroup
|
|
|
|
|
protected override void ConvertMainPropertyGroup(XElement element)
|
|
|
|
|
{
|
|
|
|
|
ChangeOrCreateNodeValue(element, "ProjectTypeGuids",
|
|
|
|
|
"{BC8A1FFA-BEE3-4634-8014-F334798102B3};" +
|
|
|
|
|
"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}");
|
2012-08-12 21:43:28 +00:00
|
|
|
|
|
|
|
|
|
//ChangeOrCreateNodeValue(element, "TargetFrameworkVersion", "4.5");
|
|
|
|
|
//ChangeOrCreateNodeValue(element, "TargetPlatformVersion", "8.0");
|
|
|
|
|
DeleteNodeIfExists(element, "TargetFrameworkVersion");
|
|
|
|
|
DeleteNodeIfExists(element, "TargetPlatformVersion");
|
|
|
|
|
|
2012-08-12 20:00:19 +00:00
|
|
|
|
DeleteNodeIfExists(element, "TargetFrameworkProfile");
|
|
|
|
|
DeleteNodeIfExists(element, "XnaFrameworkVersion");
|
|
|
|
|
DeleteNodeIfExists(element, "XnaPlatform");
|
|
|
|
|
DeleteNodeIfExists(element, "XnaProfile");
|
|
|
|
|
DeleteNodeIfExists(element, "XnaCrossPlatformGroupID");
|
|
|
|
|
DeleteNodeIfExists(element, "XnaOutputType");
|
2012-08-12 21:43:28 +00:00
|
|
|
|
DeleteNodeIfExists(element, "ApplicationIcon");
|
|
|
|
|
DeleteNodeIfExists(element, "Thumbnail");
|
|
|
|
|
DeleteNodeIfExists(element, "PublishUrl");
|
|
|
|
|
DeleteNodeIfExists(element, "Install");
|
|
|
|
|
DeleteNodeIfExists(element, "UpdateEnabled");
|
|
|
|
|
DeleteNodeIfExists(element, "UpdateMode");
|
|
|
|
|
DeleteNodeIfExists(element, "UpdateInterval");
|
|
|
|
|
DeleteNodeIfExists(element, "UpdateIntervalUnits");
|
|
|
|
|
DeleteNodeIfExists(element, "UpdatePeriodically");
|
|
|
|
|
DeleteNodeIfExists(element, "UpdateRequired");
|
|
|
|
|
DeleteNodeIfExists(element, "MapFileExtensions");
|
|
|
|
|
DeleteNodeIfExists(element, "ApplicationRevision");
|
|
|
|
|
DeleteNodeIfExists(element, "ApplicationVersion");
|
|
|
|
|
DeleteNodeIfExists(element, "IsWebBootstrapper");
|
|
|
|
|
DeleteNodeIfExists(element, "UseApplicationTrust");
|
|
|
|
|
DeleteNodeIfExists(element, "BootstrapperEnabled");
|
2012-08-12 20:00:19 +00:00
|
|
|
|
|
|
|
|
|
XElement outputTypeNode = GetOrCreateNode(element, "OutputType");
|
|
|
|
|
string outputTypeValue = outputTypeNode.Value.ToLower();
|
2012-08-12 21:43:28 +00:00
|
|
|
|
|
|
|
|
|
isCurrentProjectExecutable =
|
|
|
|
|
outputTypeValue == "winexe" ||
|
2012-08-12 20:00:19 +00:00
|
|
|
|
outputTypeValue == "appcontainerexe" ||
|
2012-08-12 21:43:28 +00:00
|
|
|
|
outputTypeValue == "exe";
|
|
|
|
|
if (isCurrentProjectExecutable)
|
2012-08-12 20:00:19 +00:00
|
|
|
|
{
|
|
|
|
|
outputTypeNode.Value = "AppContainerExe";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ConvertItemGroup
|
|
|
|
|
protected override void ConvertItemGroup(XElement element)
|
|
|
|
|
{
|
|
|
|
|
XName bootstrapperPackageName = XName.Get("BootstrapperPackage",
|
|
|
|
|
element.Name.NamespaceName);
|
|
|
|
|
|
|
|
|
|
var bootstrappers = element.Elements(bootstrapperPackageName);
|
|
|
|
|
foreach (XElement bootstrapper in bootstrappers)
|
|
|
|
|
{
|
|
|
|
|
bootstrapper.Remove();
|
|
|
|
|
}
|
2012-08-11 13:06:29 +00:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
2012-08-12 21:43:28 +00:00
|
|
|
|
#region ConvertPropertyGroup
|
|
|
|
|
protected override void ConvertPropertyGroup(XElement element)
|
|
|
|
|
{
|
|
|
|
|
DeleteNodeIfExists(element, "NoStdLib");
|
|
|
|
|
DeleteNodeIfExists(element, "XnaCompressContent");
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
2012-08-11 13:06:29 +00:00
|
|
|
|
#region Convert
|
|
|
|
|
protected override void PostConvert()
|
|
|
|
|
{
|
|
|
|
|
string namespaceName = currentProject.Root.Name.NamespaceName;
|
2012-08-12 21:43:28 +00:00
|
|
|
|
|
|
|
|
|
AddMetroVersionNode(namespaceName);
|
|
|
|
|
AddAppManifestNode(namespaceName);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region AddMetroVersionNode
|
|
|
|
|
private void AddMetroVersionNode(string namespaceName)
|
|
|
|
|
{
|
2012-08-11 13:06:29 +00:00
|
|
|
|
XName propertyGroupName = XName.Get("PropertyGroup", namespaceName);
|
|
|
|
|
XName vsVersionName = XName.Get("VisualStudioVersion", namespaceName);
|
|
|
|
|
|
|
|
|
|
XElement metroVersionElement = new XElement(propertyGroupName);
|
|
|
|
|
metroVersionElement.Add(new XAttribute("Condition",
|
|
|
|
|
" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '11.0' "));
|
|
|
|
|
metroVersionElement.Add(new XElement(vsVersionName, "11.0"));
|
|
|
|
|
currentProject.Root.Add(metroVersionElement);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
2012-08-12 21:43:28 +00:00
|
|
|
|
|
|
|
|
|
#region AddAppManifestNode
|
|
|
|
|
private void AddAppManifestNode(string namespaceName)
|
|
|
|
|
{
|
|
|
|
|
if(isCurrentProjectExecutable == false)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
XName itemGroupName = XName.Get("ItemGroup", namespaceName);
|
|
|
|
|
XName appxManifestName = XName.Get("AppxManifest", namespaceName);
|
|
|
|
|
XName subTypeName = XName.Get("SubType", namespaceName);
|
|
|
|
|
|
|
|
|
|
XElement newItemGroup = new XElement(itemGroupName);
|
|
|
|
|
XElement appManifestElement = new XElement(appxManifestName);
|
|
|
|
|
newItemGroup.Add(appManifestElement);
|
|
|
|
|
appManifestElement.Add(new XAttribute("Include", "Manifest.appxmanifest"));
|
|
|
|
|
appManifestElement.Add(new XElement(subTypeName, "Designer"));
|
|
|
|
|
currentProject.Root.Add(newItemGroup);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
2012-08-11 13:06:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|