Ejemplo n.º 1
0
 public override ConversionType GetVersion(ConversionTarget project)
 {
     if (project.IsProject && ProjectStoreHelper.DoesLanguageSupportXaml(project.ProjectStore))
     {
         Version storeVersion = project.ProjectStore.StoreVersion;
         if (storeVersion == CommonVersions.Version2_0)
         {
             return(ConversionType.BuildToolsVersion20);
         }
         if (storeVersion == CommonVersions.Version3_5)
         {
             return(ConversionType.BuildToolsVersion35);
         }
         if (storeVersion == CommonVersions.Version4_0)
         {
             return(ConversionType.BuildToolsVersion40);
         }
         if (storeVersion == null)
         {
             return(ConversionType.BuildToolsVersionNone);
         }
     }
     return(ConversionType.Unknown);
 }
        internal static bool ChangeImportPath(IProjectStore projectStore, string newVersion)
        {
            string          str;
            ProjectLanguage projectLanguage = ProjectStoreHelper.GetProjectLanguage(projectStore);

            if (!ProjectStoreHelper.DoesLanguageSupportXaml(projectLanguage))
            {
                return(false);
            }
            switch (projectLanguage)
            {
            case ProjectLanguage.CSharp:
            {
                str = "$(MSBuildExtensionsPath32)\\Microsoft\\Silverlight\\$(SilverlightVersion)\\Microsoft.Silverlight.CSharp.targets";
                break;
            }

            case ProjectLanguage.FSharp:
            {
                return(false);
            }

            case ProjectLanguage.VisualBasic:
            {
                str = "$(MSBuildExtensionsPath32)\\Microsoft\\Silverlight\\$(SilverlightVersion)\\Microsoft.Silverlight.VisualBasic.targets";
                break;
            }

            default:
            {
                return(false);
            }
            }
            string[] array = ProjectStoreHelper.GetSilverlightImports(projectStore).ToArray <string>();
            if ((int)array.Length != 0)
            {
                string[] strArrays = array;
                for (int i = 0; i < (int)strArrays.Length; i++)
                {
                    if (!projectStore.ChangeImport(strArrays[i], str))
                    {
                        return(false);
                    }
                }
            }
            else
            {
                projectStore.AddImport(str);
            }
            projectStore.SetProperty("TargetFrameworkVersion", string.Concat("v", newVersion));
            projectStore.SetProperty("TargetFrameworkIdentifier", "Silverlight");
            projectStore.SetProperty("SilverlightVersion", "$(TargetFrameworkVersion)");
            projectStore.SetStoreVersion(CommonVersions.Version4_0);
            foreach (IProjectItemData item in projectStore.GetItems("Reference"))
            {
                string metadata = item.GetMetadata("RequiredTargetFramework");
                if (string.IsNullOrEmpty(metadata) || !metadata.Trim().Equals("3.5", StringComparison.Ordinal))
                {
                    continue;
                }
                item.SetItemMetadata("RequiredTargetFramework", "3.0");
            }
            return(true);
        }