protected void CreateExecutableProject() { ProcessProject(); if (Harness.Mac) { ProjectGuid = "{" + Harness.NewStableGuid().ToString().ToUpper() + "}"; inputProject.SetProjectGuid(ProjectGuid); } else { inputProject.FixArchitectures(SimulatorArchitectures, DeviceArchitectures); inputProject.FixInfoPListInclude(Suffix); inputProject.SetExtraLinkerDefs("extra-linker-defs" + Suffix + ".xml"); } Harness.Save(inputProject, ProjectPath); if (!Harness.Mac) { ProjectGuid = inputProject.GetProjectGuid(); XmlDocument info_plist = new XmlDocument(); var target_info_plist = Path.Combine(TargetDirectory, "Info" + Suffix + ".plist"); info_plist.LoadWithoutNetworkAccess(Path.Combine(TargetDirectory, "Info.plist")); BundleIdentifier = info_plist.GetCFBundleIdentifier(); info_plist.SetMinimumOSVersion(GetMinimumOSVersion(info_plist.GetMinimumOSVersion())); info_plist.SetUIDeviceFamily(UIDeviceFamily); Harness.Save(info_plist, target_info_plist); } }
protected void CreateExecutableProject() { ProcessProject(); PostProcessExecutableProject(); Harness.Save(inputProject, ProjectPath); UpdateInfoPList(); }
public override void Convert() { var inputProject = new XmlDocument(); var xml = File.ReadAllText(TemplatePath); xml = xml.Replace("#FILES#", GetFileList()); inputProject.LoadXmlWithoutNetworkAccess(xml); switch (Flavor) { case MacFlavors.Modern: inputProject.SetTargetFrameworkIdentifier("Xamarin.Mac"); inputProject.SetTargetFrameworkVersion("v2.0"); inputProject.RemoveNode("UseXamMacFullFramework"); inputProject.AddAdditionalDefines("MOBILE;XAMMAC"); inputProject.AddReference("Mono.Security"); break; case MacFlavors.Full: inputProject.AddAdditionalDefines("XAMMAC_4_5"); break; default: throw new NotImplementedException(Flavor.ToString()); } inputProject.SetOutputPath("bin\\$(Platform)\\$(Configuration)" + FlavorSuffix); inputProject.SetIntermediateOutputPath("obj\\$(Platform)\\$(Configuration)" + FlavorSuffix); inputProject.SetAssemblyName(inputProject.GetAssemblyName() + FlavorSuffix); Harness.Save(inputProject, ProjectPath); }
void CreateWatchOSAppProject() { var csproj = new XmlDocument(); var suffix = Suffix + "-app"; csproj.LoadWithoutNetworkAccess(Path.Combine(Harness.WatchOSAppTemplate, "App.csproj")); csproj.FindAndReplace("%WATCHAPP_PATH%", Path.GetFullPath(Harness.WatchOSAppTemplate).Replace('/', '\\') + "\\"); csproj.FindAndReplace("%WATCHEXTENSION_CSPROJ%", Path.GetFileName(WatchOSExtensionProjectPath)); csproj.SetProjectReferenceValue(Path.GetFileName(WatchOSExtensionProjectPath), "Project", WatchOSExtensionGuid); csproj.SetProjectReferenceValue(Path.GetFileName(WatchOSExtensionProjectPath), "Name", Path.GetFileNameWithoutExtension(WatchOSExtensionProjectPath)); WatchOSAppGuid = "{" + Harness.NewStableGuid().ToString().ToUpper() + "}"; csproj.SetProjectGuid(WatchOSAppGuid); csproj.FixInfoPListInclude(suffix); if (MonoNativeInfo != null) { csproj.AddAdditionalDefines("MONO_NATIVE_WATCH"); MonoNativeHelper.AddProjectDefines(csproj, MonoNativeInfo.Flavor); MonoNativeHelper.RemoveSymlinkMode(csproj); } Harness.Save(csproj, WatchOSAppProjectPath); XmlDocument info_plist = new XmlDocument(); var target_info_plist = Path.Combine(TargetDirectory, $"Info{Suffix}-app.plist"); info_plist.LoadWithoutNetworkAccess(Path.Combine(Harness.WatchOSAppTemplate, "Info.plist")); info_plist.SetCFBundleIdentifier(BundleIdentifier + ".watchkitapp"); info_plist.SetPListStringValue("WKCompanionAppBundleIdentifier", BundleIdentifier); info_plist.SetPListStringValue("CFBundleName", Name); info_plist.SetMinimumOSVersion(GetMinimumOSVersion(info_plist.GetMinimumOSVersion())); Harness.Save(info_plist, target_info_plist); }
protected override void ProcessProject() { base.ProcessProject(); if (MonoNativeInfo == null) { return; } MonoNativeInfo.AddProjectDefines(inputProject); inputProject.AddAdditionalDefines("MONO_NATIVE_MAC"); XmlDocument info_plist = new XmlDocument(); var target_info_plist = Path.Combine(TargetDirectory, "Info" + Suffix + ".plist"); info_plist.LoadWithoutNetworkAccess(Path.Combine(TargetDirectory, "Info-mac.plist")); BundleIdentifier = info_plist.GetCFBundleIdentifier(); var plist_min_version = info_plist.GetPListStringValue("LSMinimumSystemVersion"); info_plist.SetPListStringValue("LSMinimumSystemVersion", GetMinimumOSVersion(plist_min_version)); inputProject.FixInfoPListInclude(Suffix); Harness.Save(info_plist, target_info_plist); }
void CreateWatchOSContainerProject() { var csproj = new XmlDocument(); csproj.LoadWithoutNetworkAccess(Path.Combine(Harness.WatchOSContainerTemplate, "Container.csproj")); csproj.FindAndReplace("%CONTAINER_PATH%", Path.GetFullPath(Harness.WatchOSContainerTemplate).Replace('/', '\\') + "\\"); csproj.FindAndReplace("%WATCHAPP_CSPROJ%", Path.GetFileName(WatchOSAppProjectPath)); csproj.SetProjectReferenceValue(Path.GetFileName(WatchOSAppProjectPath), "Name", Path.GetFileNameWithoutExtension(WatchOSAppProjectPath)); WatchOSGuid = "{" + Harness.NewStableGuid().ToString().ToUpper() + "}"; csproj.SetProjectGuid(WatchOSGuid); csproj.FixInfoPListInclude(Suffix); if (MonoNativeInfo != null) { csproj.AddAdditionalDefines("MONO_NATIVE_WATCH"); MonoNativeHelper.AddProjectDefines(csproj, MonoNativeInfo.Flavor); MonoNativeHelper.RemoveSymlinkMode(csproj); } Harness.Save(csproj, WatchOSProjectPath); XmlDocument info_plist = new XmlDocument(); var target_info_plist = Path.Combine(TargetDirectory, $"Info{Suffix}.plist"); info_plist.LoadWithoutNetworkAccess(Path.Combine(Harness.WatchOSContainerTemplate, "Info.plist")); info_plist.SetCFBundleIdentifier(BundleIdentifier); info_plist.SetCFBundleName(Name); info_plist.SetMinimumOSVersion("9.0"); Harness.Save(info_plist, target_info_plist); }
void CreateTodayContainerProject() { var csproj = new XmlDocument(); var suffix = "-today"; csproj.LoadWithoutNetworkAccess(Path.Combine(Harness.TodayContainerTemplate, "TodayContainer.csproj")); csproj.SetOutputPath("bin\\$(Platform)\\$(Configuration)" + suffix, false); csproj.SetIntermediateOutputPath("obj\\$(Platform)\\$(Configuration)" + suffix); csproj.SetProjectReferenceValue("TodayExtension.csproj", "Name", Path.GetFileNameWithoutExtension(TodayExtensionProjectPath)); csproj.SetProjectReferenceValue("TodayExtension.csproj", "Project", TodayExtensionGuid); csproj.SetProjectReferenceInclude("TodayExtension.csproj", TodayExtensionProjectPath.Replace('/', '\\')); csproj.FixCompileInclude("Main.cs", Path.Combine(Harness.TodayContainerTemplate, "Main.cs").Replace('/', '\\')); csproj.FixInfoPListInclude(suffix); TodayContainerGuid = "{" + Harness.NewStableGuid().ToString().ToUpper() + "}"; ProjectGuid = TodayContainerGuid; csproj.SetProjectGuid(TodayContainerGuid); Harness.Save(csproj, TodayContainerProjectPath); XmlDocument info_plist = new XmlDocument(); var target_info_plist = Path.Combine(TargetDirectory, "Info-today.plist"); info_plist.LoadWithoutNetworkAccess(Path.Combine(Harness.TodayContainerTemplate, "Info.plist")); info_plist.SetCFBundleIdentifier(BundleIdentifier); info_plist.SetCFBundleName(Name); info_plist.SetMinimumOSVersion("6.0"); Harness.Save(info_plist, target_info_plist); }
void CreateWatchOSExtensionProject() { var csproj = inputProject; var suffix = "-watchos-extension"; csproj.SetProjectTypeGuids("{1E2E965C-F6D2-49ED-B86E-418A60C69EEF};" + LanguageGuid); csproj.SetOutputPath("bin\\$(Platform)\\$(Configuration)" + suffix); csproj.SetIntermediateOutputPath("obj\\$(Platform)\\$(Configuration)" + suffix); csproj.RemoveTargetFrameworkIdentifier(); csproj.SetPlatformAssembly("Xamarin.WatchOS"); csproj.SetImport(IsFSharp ? "$(MSBuildExtensionsPath)\\Xamarin\\WatchOS\\Xamarin.WatchOS.AppExtension.FSharp.targets" : "$(MSBuildExtensionsPath)\\Xamarin\\WatchOS\\Xamarin.WatchOS.AppExtension.CSharp.targets"); csproj.FixProjectReferences("-watchos"); csproj.FixArchitectures("i386", "ARMv7k"); csproj.FixInfoPListInclude(suffix); csproj.SetOutputType("Library"); csproj.AddAdditionalDefines("XAMCORE_2_0;XAMCORE_3_0;FEATURE_NO_BSD_SOCKETS"); csproj.RemoveReferences("OpenTK-1.0"); var ext = IsFSharp ? "fs" : "cs"; csproj.AddCompileInclude("InterfaceController." + ext, Path.Combine(Harness.WatchOSExtensionTemplate, "InterfaceController." + ext)); csproj.SetExtraLinkerDefs("extra-linker-defs" + Suffix + ".xml"); csproj.SetMtouchUseBitcode(true, "iPhone", "Release"); csproj.SetMtouchUseLlvm(true, "iPhone", "Release"); Harness.Save(csproj, WatchOSExtensionProjectPath); WatchOSExtensionGuid = csproj.GetProjectGuid(); XmlDocument info_plist = new XmlDocument(); var target_info_plist = Path.Combine(TargetDirectory, "Info-watchos-extension.plist"); info_plist.LoadWithoutNetworkAccess(Path.Combine(TargetDirectory, "Info.plist")); BundleIdentifier = info_plist.GetCFBundleIdentifier(); info_plist.SetCFBundleIdentifier(BundleIdentifier + ".watchkitapp.watchkitextension"); info_plist.SetMinimumOSVersion("2.0"); info_plist.SetUIDeviceFamily(4); info_plist.AddPListStringValue("RemoteInterfacePrincipleClass", "InterfaceController"); info_plist.AddPListKeyValuePair("NSExtension", "dict", string.Format( @" <key>NSExtensionAttributes</key> <dict> <key>WKAppBundleIdentifier</key> <string>{0}.watchkitapp</string> </dict> <key>NSExtensionPointIdentifier</key> <string>com.apple.watchkit</string> ", BundleIdentifier)); if (!info_plist.ContainsKey("NSAppTransportSecurity")) { info_plist.AddPListKeyValuePair("NSAppTransportSecurity", "dict", @" <key>NSAllowsArbitraryLoads</key> <true/> " ); } Harness.Save(info_plist, target_info_plist); }
public virtual void Convert() { var testName = TestName == "mscorlib" ? "corlib" : TestName; var main_test_sources = Path.Combine(MonoPath, "mcs", "class", testName, testName + "_test.dll.sources"); if (!File.Exists(main_test_sources)) // TODO: revert this { return; } var main_test_files = File.ReadAllLines(main_test_sources); var watch_test_sources = Path.Combine(MonoPath, "mcs", "class", testName, testName + "_test.dll.sources"); var watch_test_files = File.ReadAllLines(watch_test_sources).Where((arg) => !string.IsNullOrEmpty(arg)); var template_path = Path.Combine(Harness.RootDirectory, "bcl-test", TestName, TestName + ".csproj.template"); var csproj_input = File.ReadAllText(template_path); var project_path = Path.Combine(Harness.RootDirectory, "bcl-test", TestName, TestName + ".csproj"); var csproj_output = project_path; var split_count = testName == "corlib" ? 2 : 1; // split corlib tests into two (library) projects, it won't build for watchOS/device otherwise (the test assembly ends up getting too big). var sb = new StringBuilder [split_count + 1]; // the last one is for the main project for (int i = 0; i < split_count + 1; i++) { sb [i] = new StringBuilder(); } Process(main_test_sources, main_test_files, "'$(TargetFrameworkIdentifier)' == 'MonoTouch' Or '$(TargetFrameworkIdentifier)' == 'Xamarin.iOS' Or '$(TargetFrameworkIdentifier)' == 'Xamarin.TVOS'", sb, split_count); Process(watch_test_sources, watch_test_files, "'$(TargetFrameworkIdentifier)' == 'Xamarin.WatchOS'", sb, split_count); if (split_count > 1) { var split_template = File.ReadAllText(Path.Combine(Harness.RootDirectory, "bcl-test", TestName, TestName + "-split.csproj.template")); for (int i = 0; i < split_count; i++) { var split_output = Path.Combine(Harness.RootDirectory, "bcl-test", TestName, TestName + "-" + i + ".csproj"); Harness.Save(split_template.Replace("#SPLIT#", (i + 1).ToString()).Replace("#FILES#", sb [i].ToString()), split_output); } Harness.Save(csproj_input.Replace("#FILES#", sb [sb.Length - 1].ToString()), csproj_output); } else { Harness.Save(csproj_input.Replace("#FILES#", sb [0].ToString()), csproj_output); } }
public XmlDocument SetInfoPListMinimumOSVersion(string template_plist, string target_plist) { var template_info_plist = template_plist; var info_plist = new XmlDocument(); info_plist.LoadWithoutNetworkAccess(template_info_plist); SetInfoPListMinimumOSVersion(info_plist, MonoNativeHelper.GetMinimumOSVersion(DevicePlatform, Flavor)); Harness.Save(info_plist, target_plist); return(info_plist); }
protected override void UpdateInfoPList() { XmlDocument info_plist = new XmlDocument(); var target_info_plist = Path.Combine(TargetDirectory, "Info" + Suffix + ".plist"); info_plist.LoadWithoutNetworkAccess(Path.Combine(TargetDirectory, "Info.plist")); BundleIdentifier = info_plist.GetCFBundleIdentifier(); info_plist.SetMinimumOSVersion(GetMinimumOSVersion(info_plist.GetMinimumOSVersion())); info_plist.SetUIDeviceFamily(UIDeviceFamily); Harness.Save(info_plist, target_info_plist); }
void CreateTodayExtensionProject() { var csproj = inputProject; var suffix = Suffix + "-extension"; csproj.SetProjectTypeGuids("{EE2C853D-36AF-4FDB-B1AD-8E90477E2198};" + LanguageGuid); csproj.SetOutputPath("bin\\$(Platform)\\$(Configuration)" + suffix); csproj.SetIntermediateOutputPath("obj\\$(Platform)\\$(Configuration)" + suffix); csproj.SetImport(IsFSharp ? "$(MSBuildExtensionsPath)\\Xamarin\\iOS\\Xamarin.iOS.AppExtension.FSharp.targets" : "$(MSBuildExtensionsPath)\\Xamarin\\iOS\\Xamarin.iOS.AppExtension.CSharp.targets"); csproj.FixInfoPListInclude(suffix); csproj.SetOutputType("Library"); csproj.AddAdditionalDefines("XAMCORE_2_0;XAMCORE_3_0;TODAY_EXTENSION"); var ext = IsFSharp ? "fs" : "cs"; csproj.AddCompileInclude("TodayExtensionMain." + ext, Path.Combine(Harness.TodayExtensionTemplate, "TodayExtensionMain." + ext), true); csproj.AddInterfaceDefinition(Path.Combine(Harness.TodayExtensionTemplate, "TodayView.storyboard").Replace('/', '\\')); csproj.SetExtraLinkerDefs("extra-linker-defs" + ExtraLinkerDefsSuffix + ".xml"); csproj.FixProjectReferences("-today"); if (MonoNativeInfo != null) { MonoNativeInfo.AddProjectDefines(csproj); csproj.AddAdditionalDefines("MONO_NATIVE_TODAY"); } Harness.Save(csproj, TodayExtensionProjectPath); TodayExtensionGuid = csproj.GetProjectGuid(); XmlDocument info_plist = new XmlDocument(); var target_info_plist = Path.Combine(TargetDirectory, $"Info{suffix}.plist"); info_plist.LoadWithoutNetworkAccess(Path.Combine(TargetDirectory, "Info.plist")); BundleIdentifier = info_plist.GetCFBundleIdentifier() + "-today"; info_plist.SetCFBundleIdentifier(BundleIdentifier + ".todayextension"); info_plist.SetMinimumOSVersion(GetMinimumOSVersion("8.0")); info_plist.AddPListStringValue("CFBundlePackageType", "XPC!"); info_plist.SetCFBundleDisplayName(Name); info_plist.AddPListKeyValuePair("NSExtension", "dict", @" <key>NSExtensionMainStoryboard</key> <string>TodayView</string> <key>NSExtensionPointIdentifier</key> <string>com.apple.widget-extension</string> "); Harness.Save(info_plist, target_info_plist); }
public void Convert() { var inputProject = new XmlDocument(); var xml = File.ReadAllText(TemplatePath); inputProject.LoadXmlWithoutNetworkAccess(xml); inputProject.SetOutputPath("bin\\$(Platform)\\$(Configuration)" + FlavorSuffix); inputProject.SetIntermediateOutputPath("obj\\$(Platform)\\$(Configuration)" + FlavorSuffix); inputProject.SetAssemblyName(inputProject.GetAssemblyName() + FlavorSuffix); AddProjectDefines(inputProject); Convert(inputProject); Harness.Save(inputProject, ProjectPath); }
void CreateWatchOSLibraryProject() { var csproj = inputProject; csproj.SetProjectTypeGuids("{FC940695-DFE0-4552-9F25-99AF4A5619A1};" + LanguageGuid); csproj.SetOutputPath("bin\\$(Platform)\\$(Configuration)" + Suffix); csproj.SetIntermediateOutputPath("obj\\$(Platform)\\$(Configuration)" + Suffix); csproj.RemoveTargetFrameworkIdentifier(); csproj.SetPlatformAssembly("Xamarin.WatchOS"); csproj.SetImport(IsBindingProject ? BindingsImports : Imports); csproj.AddAdditionalDefines("XAMCORE_2_0;XAMCORE_3_0"); csproj.FixProjectReferences(Suffix); csproj.SetExtraLinkerDefs("extra-linker-defs" + Suffix + ".xml"); csproj.FixTestLibrariesReferences(Platform); Harness.Save(csproj, WatchOSProjectPath); WatchOSGuid = csproj.GetProjectGuid(); }
public override void Convert() { var inputProject = new XmlDocument(); var xml = File.ReadAllText(TemplatePath); xml = xml.Replace("#FILES#", GetFileList()); inputProject.LoadXmlWithoutNetworkAccess(xml); // The csproj template is Xamarin.Mac/Full, so make it Modern instead inputProject.SetTargetFrameworkIdentifier("Xamarin.Mac"); inputProject.SetTargetFrameworkVersion("v2.0"); inputProject.RemoveNode("UseXamMacFullFramework"); inputProject.AddAdditionalDefines("MOBILE;XAMMAC"); inputProject.AddReference("Mono.Security"); Harness.Save(inputProject, ProjectPath); }
public override void Convert() { var testName = TestName == "mscorlib" ? "corlib" : TestName; var main_test_sources = Path.Combine(MonoPath, "mcs", "class", testName, testName + "_test.dll.sources"); var main_test_files = File.ReadAllLines(main_test_sources); var template_path = Path.Combine(Harness.RootDirectory, "bcl-test", TestName, TestName + "-mac.csproj.template"); var csproj_input = File.ReadAllText(template_path); var project_path = Path.Combine(Harness.RootDirectory, "bcl-test", TestName, TestName + "-mac.csproj"); var csproj_output = project_path; var sb = new StringBuilder[2] { new StringBuilder(), new StringBuilder() }; Process(main_test_sources, main_test_files, "", sb, 1); Harness.Save(csproj_input.Replace("#FILES#", sb[0].ToString()), csproj_output); }
void CreateWatchOSContainerProject() { var csproj = new XmlDocument(); csproj.LoadWithoutNetworkAccess(Path.Combine(Harness.WatchOSContainerTemplate, "Container.csproj")); csproj.FindAndReplace("%CONTAINER_PATH%", Path.GetFullPath(Harness.WatchOSContainerTemplate).Replace('/', '\\') + "\\"); csproj.FindAndReplace("%WATCHAPP_CSPROJ%", Path.GetFileName(WatchOSAppProjectPath)); csproj.SetProjectReferenceValue(Path.GetFileName(WatchOSAppProjectPath), "Name", Path.GetFileNameWithoutExtension(WatchOSAppProjectPath)); WatchOSGuid = "{" + Harness.NewStableGuid().ToString().ToUpper() + "}"; csproj.SetProjectGuid(WatchOSGuid); Harness.Save(csproj, WatchOSProjectPath); XmlDocument info_plist = new XmlDocument(); var target_info_plist = Path.Combine(TargetDirectory, "Info-watchos.plist"); info_plist.LoadWithoutNetworkAccess(Path.Combine(Harness.WatchOSContainerTemplate, "Info.plist")); info_plist.SetCFBundleIdentifier(BundleIdentifier); info_plist.SetCFBundleName(Name); Harness.Save(info_plist, target_info_plist); }
public void Convert() { var inputProject = new XmlDocument(); var xml = File.ReadAllText(TemplatePath); inputProject.LoadXmlWithoutNetworkAccess(xml); inputProject.SetOutputPath("bin\\$(Platform)\\$(Configuration)" + FlavorSuffix); inputProject.SetIntermediateOutputPath("obj\\$(Platform)\\$(Configuration)" + FlavorSuffix); inputProject.SetAssemblyName(inputProject.GetAssemblyName() + FlavorSuffix); var template_info_plist = Path.Combine(Path.GetDirectoryName(TemplatePath), inputProject.GetInfoPListInclude()); var target_info_plist = Path.Combine(Path.GetDirectoryName(template_info_plist), "Info" + TemplateSuffix + FlavorSuffix + ".plist"); SetInfoPListMinimumOSVersion(template_info_plist, target_info_plist); inputProject.FixInfoPListInclude(FlavorSuffix, newName: Path.GetFileName(target_info_plist)); AddProjectDefines(inputProject); Harness.Save(inputProject, ProjectPath); }
void CreateWatchOSAppProject() { var csproj = new XmlDocument(); csproj.LoadWithoutNetworkAccess(Path.Combine(Harness.WatchOSAppTemplate, "App.csproj")); csproj.FindAndReplace("%WATCHAPP_PATH%", Path.GetFullPath(Harness.WatchOSAppTemplate).Replace('/', '\\') + "\\"); csproj.FindAndReplace("%WATCHEXTENSION_CSPROJ%", Path.GetFileName(WatchOSExtensionProjectPath)); csproj.SetProjectReferenceValue(Path.GetFileName(WatchOSExtensionProjectPath), "Project", WatchOSExtensionGuid); csproj.SetProjectReferenceValue(Path.GetFileName(WatchOSExtensionProjectPath), "Name", Path.GetFileNameWithoutExtension(WatchOSExtensionProjectPath)); WatchOSAppGuid = "{" + Harness.NewStableGuid().ToString().ToUpper() + "}"; csproj.SetProjectGuid(WatchOSAppGuid); Harness.Save(csproj, WatchOSAppProjectPath); XmlDocument info_plist = new XmlDocument(); var target_info_plist = Path.Combine(TargetDirectory, "Info-watchos-app.plist"); info_plist.LoadWithoutNetworkAccess(Path.Combine(Harness.WatchOSAppTemplate, "Info.plist")); info_plist.SetCFBundleIdentifier(BundleIdentifier + ".watchkitapp"); info_plist.SetPListStringValue("WKCompanionAppBundleIdentifier", BundleIdentifier); info_plist.SetPListStringValue("CFBundleName", Name); Harness.Save(info_plist, target_info_plist); }
protected override void ExecuteInternal() { if (MonoNativeInfo == null) { return; } MonoNativeInfo.AddProjectDefines(inputProject); inputProject.AddAdditionalDefines("MONO_NATIVE_IOS"); inputProject.FixInfoPListInclude(Suffix); inputProject.SetExtraLinkerDefs("extra-linker-defs" + ExtraLinkerDefsSuffix + ".xml"); Harness.Save(inputProject, ProjectPath); XmlDocument info_plist = new XmlDocument(); var target_info_plist = Path.Combine(TargetDirectory, "Info" + Suffix + ".plist"); info_plist.LoadWithoutNetworkAccess(Path.Combine(TargetDirectory, "Info.plist")); info_plist.SetMinimumOSVersion(GetMinimumOSVersion(info_plist.GetMinimumOSVersion())); Harness.Save(info_plist, target_info_plist); }
void CreateWatchOSExtensionProject() { var csproj = inputProject; var suffix = Suffix + "-extension"; // Remove unused configurations csproj.DeleteConfiguration("iPhone", "Release-bitcode"); csproj.DeleteConfiguration("iPhone", "Release64"); csproj.DeleteConfiguration("iPhone", "Debug64"); csproj.FixArchitectures("i386", "ARMv7k", "iPhone", "Release32"); csproj.FixArchitectures("i386", "ARMv7k", "iPhone", "Debug32"); // add Release64_32 and set the correct architecture csproj.CloneConfiguration("iPhone", "Release", "Release64_32"); csproj.FixArchitectures("i386", "ARM64_32", "iPhone", "Release64_32"); // add Debug64_32 and set the correct architecture csproj.CloneConfiguration("iPhone", "Debug", "Debug64_32"); csproj.FixArchitectures("i386", "ARM64_32", "iPhone", "Debug64_32"); csproj.FixArchitectures(SimulatorArchitectures, DeviceArchitectures, "iPhoneSimulator", "Debug"); csproj.FixArchitectures(SimulatorArchitectures, DeviceArchitectures, "iPhoneSimulator", "Release"); csproj.FixArchitectures(SimulatorArchitectures, DeviceArchitectures, "iPhone", "Debug"); csproj.FixArchitectures(SimulatorArchitectures, DeviceArchitectures, "iPhone", "Release"); csproj.SetProjectTypeGuids("{1E2E965C-F6D2-49ED-B86E-418A60C69EEF};" + LanguageGuid); csproj.SetOutputPath("bin\\$(Platform)\\$(Configuration)" + suffix); csproj.SetIntermediateOutputPath("obj\\$(Platform)\\$(Configuration)" + suffix); csproj.RemoveTargetFrameworkIdentifier(); csproj.SetPlatformAssembly("Xamarin.WatchOS"); csproj.SetImport(IsFSharp ? "$(MSBuildExtensionsPath)\\Xamarin\\WatchOS\\Xamarin.WatchOS.AppExtension.FSharp.targets" : "$(MSBuildExtensionsPath)\\Xamarin\\WatchOS\\Xamarin.WatchOS.AppExtension.CSharp.targets"); csproj.FixProjectReferences("-watchos"); csproj.FixInfoPListInclude(suffix); csproj.SetOutputType("Library"); csproj.AddAdditionalDefines("BITCODE", "iPhone", "Release"); csproj.AddAdditionalDefines("XAMCORE_2_0;XAMCORE_3_0;FEATURE_NO_BSD_SOCKETS;MONOTOUCH_WATCH;"); csproj.RemoveReferences("OpenTK-1.0"); var ext = IsFSharp ? "fs" : "cs"; csproj.AddCompileInclude("InterfaceController." + ext, Path.Combine(Harness.WatchOSExtensionTemplate, "InterfaceController." + ext)); csproj.SetExtraLinkerDefs("extra-linker-defs" + ExtraLinkerDefsSuffix + ".xml"); csproj.SetMtouchUseBitcode(true, "iPhone", "Release"); csproj.SetMtouchUseLlvm(true, "iPhone", "Release"); if (MonoNativeInfo != null) { csproj.AddAdditionalDefines("MONO_NATIVE_WATCH"); MonoNativeHelper.AddProjectDefines(csproj, MonoNativeInfo.Flavor); MonoNativeHelper.RemoveSymlinkMode(csproj); } // Not linking a watch extensions requires passing -Os to the native compiler. // https://github.com/mono/mono/issues/9867 var configurations = new string [] { "Debug", "Debug32", "Debug64_32", "Release", "Release32", "Release64_32" }; foreach (var c in configurations) { var flags = "-fembed-bitcode-marker"; if (csproj.GetMtouchLink("iPhone", c) == "None") { flags += " -Os"; } csproj.AddExtraMtouchArgs($"--gcc_flags='{flags}'", "iPhone", c); } Harness.Save(csproj, WatchOSExtensionProjectPath); WatchOSExtensionGuid = csproj.GetProjectGuid(); XmlDocument info_plist = new XmlDocument(); var target_info_plist = Path.Combine(TargetDirectory, $"Info{Suffix}-extension.plist"); info_plist.LoadWithoutNetworkAccess(Path.Combine(TargetDirectory, "Info.plist")); BundleIdentifier = info_plist.GetCFBundleIdentifier() + "_watch"; if (BundleIdentifier.Length >= 58) { BundleIdentifier = BundleIdentifier.Substring(0, 57); // If the main app's bundle id is 58 characters (or sometimes more), then the watch extension crashes at launch. radar #29847128. } info_plist.SetCFBundleIdentifier(BundleIdentifier + ".watchkitapp.watchkitextension"); info_plist.SetMinimumOSVersion(GetMinimumOSVersion("2.0")); info_plist.SetUIDeviceFamily(4); info_plist.AddPListStringValue("RemoteInterfacePrincipleClass", "InterfaceController"); info_plist.AddPListKeyValuePair("NSExtension", "dict", string.Format( @" <key>NSExtensionAttributes</key> <dict> <key>WKAppBundleIdentifier</key> <string>{0}.watchkitapp</string> </dict> <key>NSExtensionPointIdentifier</key> <string>com.apple.watchkit</string> ", BundleIdentifier)); if (!info_plist.ContainsKey("NSAppTransportSecurity")) { info_plist.AddPListKeyValuePair("NSAppTransportSecurity", "dict", @" <key>NSAllowsArbitraryLoads</key> <true/> " ); } Harness.Save(info_plist, target_info_plist); }
public override void Convert() { string csprojText = ProcessCSProj(File.ReadAllText(TemplatePath), GetFileList()); Harness.Save(csprojText, ProjectPath); }
public void Convert() { var testName = TestName == "mscorlib" ? "corlib" : TestName; var main_test_sources = Path.Combine(MonoPath, "mcs", "class", testName, testName + "_test.dll.sources"); var main_test_files = File.ReadAllLines(main_test_sources); var watch_test_sources = Path.Combine(WatchMonoPath, "mcs", "class", testName, testName + "_test.dll.sources"); var watch_test_files = File.ReadAllLines(watch_test_sources); var tvos_test_sources = Path.Combine(TVOSMonoPath, "mcs", "class", testName, testName + "_test.dll.sources"); var tvos_test_files = File.ReadAllLines(tvos_test_sources); var template_path = Path.Combine(Harness.RootDirectory, "bcl-test", TestName, TestName + ".csproj.template"); var csproj_input = File.ReadAllText(template_path); var project_path = Path.Combine(Harness.RootDirectory, "bcl-test", TestName, TestName + ".csproj"); var csproj_output = project_path; var sb = new StringBuilder(); var files_path = Path.GetDirectoryName(main_test_sources).Replace("/", "\\"); foreach (var s in main_test_files) { if (string.IsNullOrEmpty(s)) { continue; } if (IsNotSupported(main_test_sources, s)) { continue; } sb.AppendFormat(" <Compile Include=\"{0}\\Test\\{1}\" Condition=\"'$(TargetFrameworkIdentifier)' == 'MonoTouch' Or '$(TargetFrameworkIdentifier)' == 'Xamarin.iOS'\">\r\n", files_path, s.Replace("/", "\\").Trim()); var link_path = Path.GetDirectoryName(s); if (string.IsNullOrEmpty(link_path) || link_path [0] == '.') { sb.AppendFormat(" <Link>{0}</Link>\r\n", Path.GetFileName(s)); } else { sb.AppendFormat(" <Link>{0}\\{1}</Link>\r\n", link_path, Path.GetFileName(s)); } sb.AppendFormat(" </Compile>\r\n"); } var watch_files_path = Path.GetDirectoryName(watch_test_sources).Replace("/", "\\"); foreach (var s in watch_test_files) { if (string.IsNullOrEmpty(s)) { continue; } if (IsNotSupported(watch_test_sources, s)) { continue; } sb.AppendFormat(" <Compile Include=\"{0}\\Test\\{1}\" Condition=\"'$(TargetFrameworkIdentifier)' == 'Xamarin.WatchOS'\">\r\n", watch_files_path, s.Replace("/", "\\").Trim()); var link_path = Path.GetDirectoryName(s); if (string.IsNullOrEmpty(link_path) || link_path [0] == '.') { sb.AppendFormat(" <Link>{0}</Link>\r\n", Path.GetFileName(s)); } else { sb.AppendFormat(" <Link>{0}\\{1}</Link>\r\n", link_path, Path.GetFileName(s)); } sb.AppendFormat(" </Compile>\r\n"); } var tvos_files_path = Path.GetDirectoryName(tvos_test_sources).Replace("/", "\\"); foreach (var s in tvos_test_files) { if (string.IsNullOrEmpty(s)) { continue; } if (IsNotSupported(tvos_test_sources, s)) { continue; } sb.AppendFormat(" <Compile Include=\"{0}\\Test\\{1}\" Condition=\"'$(TargetFrameworkIdentifier)' == 'Xamarin.TVOS'\">\r\n", tvos_files_path, s.Replace("/", "\\").Trim()); var link_path = Path.GetDirectoryName(s); if (string.IsNullOrEmpty(link_path) || link_path [0] == '.') { sb.AppendFormat(" <Link>{0}</Link>\r\n", Path.GetFileName(s)); } else { sb.AppendFormat(" <Link>{0}\\{1}</Link>\r\n", link_path, Path.GetFileName(s)); } sb.AppendFormat(" </Compile>\r\n"); } Harness.Save(csproj_input.Replace("#FILES#", sb.ToString()), csproj_output); }
public static void CreateSolution(Harness harness, IEnumerable <Target> targets, Target exeTarget, string infix) { var folders = new StringBuilder(); var srcDirectory = Path.Combine(harness.RootDirectory, "..", "src"); var sln_path = exeTarget == null?Path.Combine(harness.RootDirectory, "tests-" + infix + ".sln") : Path.Combine(Path.GetDirectoryName(exeTarget.ProjectPath), Path.GetFileNameWithoutExtension(exeTarget.ProjectPath) + ".sln"); using (var writer = new StringWriter()) { writer.WriteLine(); writer.WriteLine("Microsoft Visual Studio Solution File, Format Version 11.00"); writer.WriteLine("# Visual Studio 2010"); foreach (var target in targets) { var relatedProjects = target.GetRelatedProjects(); var hasRelatedProjects = relatedProjects != null; var folderGuid = string.Empty; var useFolders = hasRelatedProjects && target.IsExe && exeTarget == null; if (hasRelatedProjects && target.IsExe) { if (exeTarget == null) { CreateSolution(harness, targets, target, infix); // create a solution for just this test project as well } else if (exeTarget != target) { continue; } } if (useFolders) { folderGuid = Guid.NewGuid().ToString().ToUpperInvariant(); writer.WriteLine("Project(\"{{2150E333-8FDC-42A3-9474-1A3956D46DE8}}\") = \"{0}\", \"{0}\", \"{{{1}}}\"", target.Name, folderGuid); writer.WriteLine("EndProject"); } writer.WriteLine("Project(\"{3}\") = \"{0}\", \"{1}\", \"{2}\"", Path.GetFileNameWithoutExtension(target.ProjectPath), FixProjectPath(sln_path, Path.GetFullPath(target.ProjectPath)), target.ProjectGuid, target.LanguageGuid); writer.WriteLine("EndProject"); if (hasRelatedProjects && target.IsExe) { foreach (var rp in relatedProjects) { writer.WriteLine("Project(\"{3}\") = \"{0}\", \"{1}\", \"{2}\"", Path.GetFileNameWithoutExtension(rp.ProjectPath), FixProjectPath(sln_path, Path.GetFullPath(rp.ProjectPath)), rp.Guid, target.LanguageGuid); writer.WriteLine("EndProject"); } } if (useFolders) { folders.AppendFormat("\t\t{0} = {{{1}}}\n", target.ProjectGuid, folderGuid); foreach (var rp in relatedProjects) { folders.AppendFormat("\t\t{0} = {{{1}}}\n", rp.Guid, folderGuid); } } } // Add reference to MonoTouch.NUnitLite project string configuration; var proj_path = Path.GetFullPath(Path.Combine(srcDirectory, "MonoTouch.NUnitLite." + infix + ".csproj")); if (!File.Exists(proj_path)) { proj_path = Path.GetFullPath(Path.Combine(srcDirectory, "MonoTouch.NUnitLite.csproj")); } AddProjectToSolution(harness, sln_path, writer, proj_path, out configuration); writer.WriteLine("Global"); writer.WriteLine("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution"); writer.WriteLine("\t\tDebug|iPhoneSimulator = Debug|iPhoneSimulator"); writer.WriteLine("\t\tRelease|iPhoneSimulator = Release|iPhoneSimulator"); writer.WriteLine("\t\tDebug|iPhone = Debug|iPhone"); writer.WriteLine("\t\tRelease|iPhone = Release|iPhone"); writer.WriteLine("\t\tRelease-bitcode|iPhone = Release-bitcode|iPhone"); writer.WriteLine("\t\tDebug|Any CPU = Debug|Any CPU"); writer.WriteLine("\t\tRelease|Any CPU = Release|Any CPU"); writer.WriteLine("\tEndGlobalSection"); writer.WriteLine("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution"); var exePlatforms = new string[] { "iPhone", "iPhoneSimulator" }; var configurations = new string[] { "Debug", "Release", "Release-bitcode" }; foreach (var target in targets) { if (target.IsExe && exeTarget != null && target != exeTarget) { continue; } foreach (var conf in configurations) { if (target.IsExe) { foreach (var platform in exePlatforms) { writer.WriteLine("\t\t{0}.{1}|{2}.ActiveCfg = {1}|{2}", target.ProjectGuid, conf, platform); writer.WriteLine("\t\t{0}.{1}|{2}.Build.0 = {1}|{2}", target.ProjectGuid, conf, platform); } } else { foreach (var platform in new string[] { "Any CPU", "iPhone", "iPhoneSimulator" }) { writer.WriteLine("\t\t{0}.{1}|{2}.ActiveCfg = {1}|Any CPU", target.ProjectGuid, conf, platform); writer.WriteLine("\t\t{0}.{1}|{2}.Build.0 = {1}|Any CPU", target.ProjectGuid, conf, platform); } } } if (target.IsExe) { var relatedProjects = target.GetRelatedProjects(); if (relatedProjects != null) { foreach (var rp in relatedProjects) { foreach (var conf in configurations) { foreach (var platform in exePlatforms) { writer.WriteLine("\t\t{0}.{1}|{2}.ActiveCfg = {1}|{2}", rp.Guid, conf, platform); writer.WriteLine("\t\t{0}.{1}|{2}.Build.0 = {1}|{2}", rp.Guid, conf, platform); } } } } } } writer.Write(configuration); writer.WriteLine("\tEndGlobalSection"); if (folders.Length > 0) { writer.WriteLine("\tGlobalSection(NestedProjects) = preSolution"); writer.Write(folders.ToString()); writer.WriteLine("\tEndGlobalSection"); } writer.WriteLine("EndGlobal"); harness.Save(writer, sln_path); } }