Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo.moya@xamarin.com>2019-07-25 19:28:57 +0300
committerGitHub <noreply@github.com>2019-07-25 19:28:57 +0300
commite974c8451d95cfaad3cfbb7eba9cde49a4dd3695 (patch)
tree274339bb83b9868de6bb9dc973aff66554e71e7d /main/src/addins
parentb4a2b5332741b84bcb8af627efccd1cc57637909 (diff)
parentcfec082b1c89dcdfca75bc94378fbf705a379538 (diff)
Merge pull request #8234 from mono/pr-select-browser
Allow selection of browser for ASP.NET Core projects
Diffstat (limited to 'main/src/addins')
-rw-r--r--main/src/addins/MacPlatform/MacInterop/CoreFoundation.cs70
-rw-r--r--main/src/addins/MacPlatform/MacPlatform.cs26
-rw-r--r--main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore.csproj1
-rw-r--r--main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreExecutionCommand.cs2
-rw-r--r--main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreExecutionHandler.cs26
-rw-r--r--main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreExecutionTarget.cs45
-rw-r--r--main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreProjectExtension.cs15
-rw-r--r--main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Tests/MonoDevelop.DotNetCore.Tests/DotNetCoreProjectTemplateTests.cs96
-rw-r--r--main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreExecutionCommand.cs12
-rw-r--r--main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreExecutionHandler.cs54
10 files changed, 160 insertions, 187 deletions
diff --git a/main/src/addins/MacPlatform/MacInterop/CoreFoundation.cs b/main/src/addins/MacPlatform/MacInterop/CoreFoundation.cs
index e2d4ab8949..8fbdcd6814 100644
--- a/main/src/addins/MacPlatform/MacInterop/CoreFoundation.cs
+++ b/main/src/addins/MacPlatform/MacInterop/CoreFoundation.cs
@@ -150,75 +150,5 @@ namespace MonoDevelop.MacInterop
Shell = 0x00000008,
All = 0xFFFFFFFF
}
-
- public static IntPtr CreatePathUrl (string path)
- {
- IntPtr str = IntPtr.Zero;
- IntPtr url = IntPtr.Zero;
- try {
- str = CreateString (path);
- if (str == IntPtr.Zero)
- throw new Exception ("CreateString failed");
- url = CFURLCreateWithFileSystemPath (IntPtr.Zero, str, CFUrlPathStyle.Posix, false);
- if (url == IntPtr.Zero)
- throw new Exception ("CFURLCreateWithFileSystemPath failed");
- return url;
- } finally {
- if (str != IntPtr.Zero)
- Release (str);
- }
- }
-
- public static string UrlToPath (IntPtr url)
- {
- IntPtr str = IntPtr.Zero;
- try {
- str = CFURLCopyFileSystemPath (url, CFUrlPathStyle.Posix);
- return str == IntPtr.Zero? null : FetchString (str);
- } finally {
- if (str != IntPtr.Zero)
- Release (str);
- }
- }
-
- public static string GetApplicationUrl (string filePath, LSRolesMask roles)
- {
- IntPtr url = IntPtr.Zero;
- try {
- url = CreatePathUrl (filePath);
- IntPtr appUrl = IntPtr.Zero;
- if (LSGetApplicationForURL (url, roles, IntPtr.Zero, ref appUrl) == 0 && appUrl != IntPtr.Zero)
- return UrlToPath (appUrl);
- return null;
- } finally {
- if (url != IntPtr.Zero)
- Release (url);
- }
- }
-
- public static string[] GetApplicationUrls (string filePath, LSRolesMask roles)
- {
- IntPtr url = IntPtr.Zero;
- IntPtr arr = IntPtr.Zero;
- try {
- url = CreatePathUrl (filePath);
- arr = LSCopyApplicationURLsForURL (url, roles);
- if (arr == IntPtr.Zero)
- return new string[0];
- int count = CFArrayGetCount (arr);
- string[] values = new string [count];
- for (int i = 0; i < values.Length; i++ ) {
- var u = CFArrayGetValueAtIndex (arr, i);
- if (u != IntPtr.Zero)
- values[i] = UrlToPath (u);
- }
- return values;
- } finally {
- if (url != IntPtr.Zero)
- Release (url);
- if (arr != IntPtr.Zero)
- Release (arr);
- }
- }
}
}
diff --git a/main/src/addins/MacPlatform/MacPlatform.cs b/main/src/addins/MacPlatform/MacPlatform.cs
index 49cadaa103..354d857363 100644
--- a/main/src/addins/MacPlatform/MacPlatform.cs
+++ b/main/src/addins/MacPlatform/MacPlatform.cs
@@ -980,18 +980,19 @@ namespace MonoDevelop.MacIntegration
checkUniqueName.Add ("MonoDevelop");
checkUniqueName.Add (BrandingService.ApplicationName);
- string def = MonoDevelop.MacInterop.CoreFoundation.GetApplicationUrl (filename,
- MonoDevelop.MacInterop.CoreFoundation.LSRolesMask.All);
+ var def = global::CoreServices.LaunchServices.GetDefaultApplicationUrlForUrl (NSUrl.FromString (filename));
var apps = new List<DesktopApplication> ();
- foreach (var app in MonoDevelop.MacInterop.CoreFoundation.GetApplicationUrls (filename,
- MonoDevelop.MacInterop.CoreFoundation.LSRolesMask.All)) {
- if (string.IsNullOrEmpty (app) || !checkUniquePath.Add (app))
- continue;
- var name = NSFileManager.DefaultManager.DisplayName (app);
- if (checkUniqueName.Add (name))
- apps.Add (new MacDesktopApplication (app, name, def != null && def == app));
+ var retrievedApps = global::CoreServices.LaunchServices.GetApplicationUrlsForUrl (NSUrl.FromString (filename), global::CoreServices.LSRoles.All);
+ if (retrievedApps != null) {
+ foreach (var app in retrievedApps) {
+ if (string.IsNullOrEmpty (app.Path) || !checkUniquePath.Add (app.Path))
+ continue;
+ if (checkUniqueName.Add (app.LastPathComponent)) {
+ apps.Add (new MacDesktopApplication (app.Path, Path.GetFileNameWithoutExtension (app.LastPathComponent), def != null && def == app));
+ }
+ }
}
apps.Sort ((DesktopApplication a, DesktopApplication b) => {
@@ -1012,8 +1013,11 @@ namespace MonoDevelop.MacIntegration
public override void Launch (params string[] files)
{
- foreach (var file in files)
- NSWorkspace.SharedWorkspace.OpenFile (file, Id);
+ NSWorkspace.SharedWorkspace.OpenUrls (
+ Array.ConvertAll (files, file => NSUrl.FromString (file)),
+ NSBundle.FromPath (Id).BundleIdentifier,
+ NSWorkspaceLaunchOptions.Default,
+ NSAppleEventDescriptor.DescriptorWithBoolean (true));
}
}
diff --git a/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore.csproj b/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore.csproj
index ba66ded95c..986ea86ede 100644
--- a/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore.csproj
+++ b/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore.csproj
@@ -46,6 +46,7 @@
<Compile Include="MonoDevelop.AspNetCore\LaunchProfileDataExtensions.cs" />
<Compile Include="MonoDevelop.AspNetCore\LaunchProfileProvider.cs" />
<Compile Include="MonoDevelop.AspNetCore\AspNetCoreNestingRulesProvider.cs" />
+ <Compile Include="MonoDevelop.AspNetCore\AspNetCoreExecutionTarget.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\MonoDevelop.AspNetCore.addin.xml" />
diff --git a/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreExecutionCommand.cs b/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreExecutionCommand.cs
index 2c1d3c471b..da240f9e9a 100644
--- a/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreExecutionCommand.cs
+++ b/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreExecutionCommand.cs
@@ -28,7 +28,7 @@ using MonoDevelop.DotNetCore;
namespace MonoDevelop.AspNetCore
{
- public class AspNetCoreExecutionCommand : DotNetCoreExecutionCommand
+ public class AspNetCoreExecutionCommand : DotNetCoreBaseExecutionCommand
{
public AspNetCoreExecutionCommand (string directory, string outputPath, string arguments)
: base (directory, outputPath, arguments)
diff --git a/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreExecutionHandler.cs b/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreExecutionHandler.cs
index 1c93be2f29..0453fd8c30 100644
--- a/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreExecutionHandler.cs
+++ b/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreExecutionHandler.cs
@@ -24,14 +24,13 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using MonoDevelop.Core;
-using MonoDevelop.Core.Execution;
-using MonoDevelop.Ide;
using System;
using System.Linq;
-using System.Threading;
using System.Threading.Tasks;
using System.Net.Sockets;
+using MonoDevelop.Core;
+using MonoDevelop.Core.Execution;
+using MonoDevelop.Ide;
namespace MonoDevelop.AspNetCore
{
@@ -57,13 +56,15 @@ namespace MonoDevelop.AspNetCore
dotNetCoreCommand.WorkingDirectory,
console,
envVariables);
+
if (dotNetCoreCommand.LaunchBrowser) {
- LaunchBrowser (dotNetCoreCommand.ApplicationURL, dotNetCoreCommand.LaunchURL, process.Task).Ignore ();
+ LaunchBrowserAsync (dotNetCoreCommand.ApplicationURL, dotNetCoreCommand.LaunchURL, dotNetCoreCommand.Target, process.Task).Ignore ();
}
+
return process;
}
- public static async Task LaunchBrowser (string appUrl, string launchUrl, Task processTask)
+ public static async Task LaunchBrowserAsync (string appUrl, string launchUrl, ExecutionTarget target, Task processTask)
{
launchUrl = launchUrl ?? "";
Uri launchUri;
@@ -84,12 +85,12 @@ namespace MonoDevelop.AspNetCore
//Try to connect every 50ms while process is running
while (!processTask.IsCompleted) {
- await Task.Delay (50);
+ await Task.Delay (50).ConfigureAwait (false);
using (var tcpClient = new TcpClient ()) {
try {
- tcpClient.Connect (launchUri.Host, launchUri.Port);
+ await tcpClient.ConnectAsync (launchUri.Host, launchUri.Port).ConfigureAwait (false);
// pause briefly to allow the server process to initialize
- await Task.Delay (TimeSpan.FromSeconds (1));
+ await Task.Delay (TimeSpan.FromSeconds (1)).ConfigureAwait (false);
break;
} catch {
}
@@ -102,7 +103,12 @@ namespace MonoDevelop.AspNetCore
}
// Process is still alive hence we succesfully connected inside loop to web server, launch browser
- IdeServices.DesktopService.ShowUrl (launchUri.AbsoluteUri);
+ var aspNetCoreTarget = target as AspNetCoreExecutionTarget;
+ if (aspNetCoreTarget != null && !aspNetCoreTarget.DesktopApplication.IsDefault) {
+ aspNetCoreTarget.DesktopApplication.Launch (launchUri.AbsoluteUri);
+ } else {
+ IdeServices.DesktopService.ShowUrl (launchUri.AbsoluteUri);
+ }
}
}
} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreExecutionTarget.cs b/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreExecutionTarget.cs
new file mode 100644
index 0000000000..86cef8a38e
--- /dev/null
+++ b/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreExecutionTarget.cs
@@ -0,0 +1,45 @@
+//
+// AspNetCoreExecutionTarget.cs
+//
+// Author:
+// Rodrigo Moya <rodrigo.moya@xamarin.com>
+//
+// Copyright (c) 2019 Microsoft, Inc. (http://www.microsoft.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using MonoDevelop.Core.Execution;
+using MonoDevelop.Ide.Desktop;
+
+namespace MonoDevelop.AspNetCore
+{
+ class AspNetCoreExecutionTarget : ExecutionTarget
+ {
+ internal AspNetCoreExecutionTarget (DesktopApplication desktopApplication)
+ {
+ DesktopApplication = desktopApplication;
+ }
+
+ public override string Name => DesktopApplication.DisplayName;
+
+ public override string Id => DesktopApplication.Id;
+
+ public DesktopApplication DesktopApplication { get; }
+ }
+}
diff --git a/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreProjectExtension.cs b/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreProjectExtension.cs
index ae503d3388..d7176986f1 100644
--- a/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreProjectExtension.cs
+++ b/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreProjectExtension.cs
@@ -24,6 +24,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
+using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MonoDevelop.Core;
@@ -100,6 +101,20 @@ namespace MonoDevelop.AspNetCore
return base.OnExecute (monitor, context, configuration, runConfiguration);
}
+ protected override IEnumerable<ExecutionTarget> OnGetExecutionTargets (ConfigurationSelector configuration)
+ {
+ var result = new List<ExecutionTarget> ();
+ foreach (var browser in IdeServices.DesktopService.GetApplications ("https://localhost")) {
+ if (browser.IsDefault) {
+ result.Insert (0, new AspNetCoreExecutionTarget (browser));
+ } else {
+ result.Add (new AspNetCoreExecutionTarget (browser));
+ }
+ }
+
+ return result.Count > 0 ? result : base.OnGetExecutionTargets (configuration);
+ }
+
async Task CheckCertificateThenExecute (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
{
if (AspNetCoreCertificateManager.CheckDevelopmentCertificateIsTrusted (Project, runConfiguration)) {
diff --git a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Tests/MonoDevelop.DotNetCore.Tests/DotNetCoreProjectTemplateTests.cs b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Tests/MonoDevelop.DotNetCore.Tests/DotNetCoreProjectTemplateTests.cs
index f4485c2e44..b27555e83c 100644
--- a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Tests/MonoDevelop.DotNetCore.Tests/DotNetCoreProjectTemplateTests.cs
+++ b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Tests/MonoDevelop.DotNetCore.Tests/DotNetCoreProjectTemplateTests.cs
@@ -25,6 +25,7 @@
// THE SOFTWARE.
using System;
+using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MonoDevelop.Ide.Templates;
@@ -32,7 +33,7 @@ using MonoDevelop.Projects;
using NUnit.Framework;
using IdeUnitTests;
using MonoDevelop.Projects.FileNesting;
-
+using MonoDevelop.Core.Execution;
namespace MonoDevelop.DotNetCore.Tests
{
@@ -264,18 +265,18 @@ namespace MonoDevelop.DotNetCore.Tests
await CreateFromTemplateAndBuild ("NetCore2x", templateId, parameters);
}
- [TestCase ("Microsoft.Web.Empty.CSharp", "UseNetCore21=true")]
- [TestCase ("Microsoft.Web.Empty.FSharp", "UseNetCore21=true")]
- [TestCase ("Microsoft.Web.Mvc.CSharp", "UseNetCore21=true")]
- [TestCase ("Microsoft.Web.Mvc.FSharp", "UseNetCore21=true")]
- [TestCase ("Microsoft.Web.RazorPages.CSharp", "UseNetCore21=true")]
- [TestCase ("Microsoft.Web.WebApi.CSharp", "UseNetCore21=true")]
- [TestCase ("Microsoft.Web.WebApi.FSharp", "UseNetCore21=true")]
- [TestCase ("Microsoft.Web.Razor.Library.CSharp", "UseNetCore21=true")]
- [TestCase ("Microsoft.Web.Spa.Angular.CSharp", "UseNetCore21=true")]
- [TestCase ("Microsoft.Web.Spa.React.CSharp", "UseNetCore21=true")]
- [TestCase ("Microsoft.Web.Spa.ReactRedux.CSharp", "UseNetCore21=true")]
- public async Task AspNetCore21 (string templateId, string parameters)
+ [TestCase ("Microsoft.Web.Empty.CSharp", "UseNetCore21=true", true)]
+ [TestCase ("Microsoft.Web.Empty.FSharp", "UseNetCore21=true", true)]
+ [TestCase ("Microsoft.Web.Mvc.CSharp", "UseNetCore21=true", true)]
+ [TestCase ("Microsoft.Web.Mvc.FSharp", "UseNetCore21=true", true)]
+ [TestCase ("Microsoft.Web.RazorPages.CSharp", "UseNetCore21=true", true)]
+ [TestCase ("Microsoft.Web.WebApi.CSharp", "UseNetCore21=true", true)]
+ [TestCase ("Microsoft.Web.WebApi.FSharp", "UseNetCore21=true", true)]
+ [TestCase ("Microsoft.Web.Razor.Library.CSharp", "UseNetCore21=true", false)]
+ [TestCase ("Microsoft.Web.Spa.Angular.CSharp", "UseNetCore21=true", true)]
+ [TestCase ("Microsoft.Web.Spa.React.CSharp", "UseNetCore21=true", true)]
+ [TestCase ("Microsoft.Web.Spa.ReactRedux.CSharp", "UseNetCore21=true", true)]
+ public async Task AspNetCore21 (string templateId, string parameters, bool checkExecutionTargets)
{
if (!IsDotNetCoreSdk21Installed ()) {
Assert.Ignore (".NET Core 2.1 SDK is not installed - required by project template.");
@@ -286,21 +287,21 @@ namespace MonoDevelop.DotNetCore.Tests
Assert.Ignore ("Node is not installed - required by project template");
}
- await CreateFromTemplateAndBuild ("NetCore2x", templateId, parameters, CheckAspNetCoreNestingRules);
+ await CreateFromTemplateAndBuild ("NetCore2x", templateId, parameters, CheckAspNetCoreNestingRules, checkExecutionTargets);
}
- [TestCase ("Microsoft.Web.Empty.CSharp", "UseNetCore22=true")]
- [TestCase ("Microsoft.Web.Empty.FSharp", "UseNetCore22=true")]
- [TestCase ("Microsoft.Web.Mvc.CSharp", "UseNetCore22=true")]
- [TestCase ("Microsoft.Web.Mvc.FSharp", "UseNetCore22=true")]
- [TestCase ("Microsoft.Web.RazorPages.CSharp", "UseNetCore22=true")]
- [TestCase ("Microsoft.Web.WebApi.CSharp", "UseNetCore22=true")]
- [TestCase ("Microsoft.Web.WebApi.FSharp", "UseNetCore22=true")]
- [TestCase ("Microsoft.Web.Razor.Library.CSharp", "UseNetCore22=true")]
- [TestCase ("Microsoft.Web.Spa.Angular.CSharp", "UseNetCore22=true")]
- [TestCase ("Microsoft.Web.Spa.React.CSharp", "UseNetCore22=true")]
- [TestCase ("Microsoft.Web.Spa.ReactRedux.CSharp", "UseNetCore22=true")]
- public async Task AspNetCore22 (string templateId, string parameters)
+ [TestCase ("Microsoft.Web.Empty.CSharp", "UseNetCore22=true", true)]
+ [TestCase ("Microsoft.Web.Empty.FSharp", "UseNetCore22=true", true)]
+ [TestCase ("Microsoft.Web.Mvc.CSharp", "UseNetCore22=true", true)]
+ [TestCase ("Microsoft.Web.Mvc.FSharp", "UseNetCore22=true", true)]
+ [TestCase ("Microsoft.Web.RazorPages.CSharp", "UseNetCore22=true", true)]
+ [TestCase ("Microsoft.Web.WebApi.CSharp", "UseNetCore22=true", true)]
+ [TestCase ("Microsoft.Web.WebApi.FSharp", "UseNetCore22=true", true)]
+ [TestCase ("Microsoft.Web.Razor.Library.CSharp", "UseNetCore22=true", false)]
+ [TestCase ("Microsoft.Web.Spa.Angular.CSharp", "UseNetCore22=true", true)]
+ [TestCase ("Microsoft.Web.Spa.React.CSharp", "UseNetCore22=true", true)]
+ [TestCase ("Microsoft.Web.Spa.ReactRedux.CSharp", "UseNetCore22=true", true)]
+ public async Task AspNetCore22 (string templateId, string parameters, bool checkExecutionTargets)
{
if (!IsDotNetCoreSdk22Installed ()) {
Assert.Ignore (".NET Core 2.2 SDK is not installed - required by project template.");
@@ -311,22 +312,21 @@ namespace MonoDevelop.DotNetCore.Tests
Assert.Ignore ("Node is not installed - required by project template");
}
- await CreateFromTemplateAndBuild ("NetCore2x", templateId, parameters, CheckAspNetCoreNestingRules);
+ await CreateFromTemplateAndBuild ("NetCore2x", templateId, parameters, CheckAspNetCoreNestingRules, checkExecutionTargets);
}
- [Ignore ("Requires .NET Core App 3.0 runtime")]
- [TestCase ("Microsoft.Web.Empty.CSharp", "UseNetCore30=true")]
- [TestCase ("Microsoft.Web.Empty.FSharp", "UseNetCore30=true")]
- [TestCase ("Microsoft.Web.Mvc.CSharp", "UseNetCore30=true")]
- [TestCase ("Microsoft.Web.Mvc.FSharp", "UseNetCore30=true")]
- [TestCase ("Microsoft.Web.RazorPages.CSharp", "UseNetCore30=true")]
- [TestCase ("Microsoft.Web.WebApi.CSharp", "UseNetCore30=true")]
- [TestCase ("Microsoft.Web.WebApi.FSharp", "UseNetCore30=true")]
- [TestCase ("Microsoft.Web.Razor.Library.CSharp", "UseNetCore30=true")]
- [TestCase ("Microsoft.Web.Spa.Angular.CSharp", "UseNetCore30=true")]
- [TestCase ("Microsoft.Web.Spa.React.CSharp", "UseNetCore30=true")]
- [TestCase ("Microsoft.Web.Spa.ReactRedux.CSharp", "UseNetCore30=true")]
- public async Task AspNetCore30 (string templateId, string parameters)
+ [TestCase ("Microsoft.Web.Empty.CSharp", "UseNetCore30=true", true)]
+ [TestCase ("Microsoft.Web.Empty.FSharp", "UseNetCore30=true", true)]
+ [TestCase ("Microsoft.Web.Mvc.CSharp", "UseNetCore30=true", true)]
+ [TestCase ("Microsoft.Web.Mvc.FSharp", "UseNetCore30=true", true)]
+ [TestCase ("Microsoft.Web.RazorPages.CSharp", "UseNetCore30=true", true)]
+ [TestCase ("Microsoft.Web.WebApi.CSharp", "UseNetCore30=true", true)]
+ [TestCase ("Microsoft.Web.WebApi.FSharp", "UseNetCore30=true", true)]
+ [TestCase ("Microsoft.Web.Razor.Library.CSharp", "UseNetCore30=true", false)]
+ [TestCase ("Microsoft.Web.Spa.Angular.CSharp", "UseNetCore30=true", true)]
+ [TestCase ("Microsoft.Web.Spa.React.CSharp", "UseNetCore30=true", true)]
+ [TestCase ("Microsoft.Web.Spa.ReactRedux.CSharp", "UseNetCore30=true", true)]
+ public async Task AspNetCore30 (string templateId, string parameters, bool checkExecutionTargets)
{
if (!IsDotNetCoreSdk30Installed ()) {
Assert.Ignore (".NET Core 3.0 SDK is not installed - required by project template.");
@@ -337,7 +337,7 @@ namespace MonoDevelop.DotNetCore.Tests
Assert.Ignore ("Node is not installed - required by project template");
}
- await CreateFromTemplateAndBuild ("NetCore30", templateId, parameters, CheckAspNetCoreNestingRules);
+ await CreateFromTemplateAndBuild ("NetCore30", templateId, parameters, CheckAspNetCoreNestingRules, checkExecutionTargets);
}
static bool IsDotNetCoreSdk2xInstalled ()
@@ -366,7 +366,7 @@ namespace MonoDevelop.DotNetCore.Tests
return DotNetCoreSdk.Versions.Any (version => version.Major == 3 && version.Minor == 0);
}
- static async Task CreateFromTemplateAndBuild (string basename, string templateId, string parameters, Action<Solution> preBuildChecks = null)
+ static async Task CreateFromTemplateAndBuild (string basename, string templateId, string parameters, Action<Solution> preBuildChecks = null, bool checkExecutionTargets = false)
{
using (var ptt = new ProjectTemplateTest (basename, templateId)) {
@@ -377,6 +377,18 @@ namespace MonoDevelop.DotNetCore.Tests
var template = await ptt.CreateAndBuild (preBuildChecks);
CheckProjectTypeGuids (ptt.Solution, GetProjectTypeGuid (template));
+ // Blacklist library projects, which don't get any execution target
+ if (checkExecutionTargets) {
+ foreach (var p in ptt.Solution.GetAllProjects ().OfType<DotNetProject> ()) {
+ foreach (var config in p.Configurations) {
+ var targets = p.GetExecutionTargets (config.Selector)?.ToList () ?? new List<ExecutionTarget> ();
+ if (System.IO.Directory.Exists ("/Applications/Safari.app"))
+ Assert.True (targets.Any (x => x.Name.Contains ("Safari")), $"Configuration {config.Name} didn't contain Safari");
+ if (System.IO.Directory.Exists ("/Applications/Google Chrome.app"))
+ Assert.True (targets.Any (x => x.Name.Contains ("Google Chrome")), $"Configuration {config.Name} didn't contain Chrome");
+ }
+ }
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreExecutionCommand.cs b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreExecutionCommand.cs
index 646fb372fc..de4542a37b 100644
--- a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreExecutionCommand.cs
+++ b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreExecutionCommand.cs
@@ -28,9 +28,9 @@ using MonoDevelop.Core.Execution;
namespace MonoDevelop.DotNetCore
{
- public class DotNetCoreExecutionCommand : ProcessExecutionCommand
+ public class DotNetCoreBaseExecutionCommand : ProcessExecutionCommand
{
- public DotNetCoreExecutionCommand (string directory, string outputPath, string arguments)
+ public DotNetCoreBaseExecutionCommand (string directory, string outputPath, string arguments)
{
WorkingDirectory = directory;
OutputPath = outputPath;
@@ -50,4 +50,12 @@ namespace MonoDevelop.DotNetCore
public string ApplicationURL { get; set; }
public PipeTransportSettings PipeTransport { get; set; }
}
+
+ public class DotNetCoreExecutionCommand : DotNetCoreBaseExecutionCommand
+ {
+ public DotNetCoreExecutionCommand (string directory, string outputPath, string arguments)
+ : base (directory, outputPath, arguments)
+ {
+ }
+ }
} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreExecutionHandler.cs b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreExecutionHandler.cs
index 01f0858897..272092479d 100644
--- a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreExecutionHandler.cs
+++ b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreExecutionHandler.cs
@@ -24,14 +24,10 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using MonoDevelop.Core;
-using MonoDevelop.Core.Execution;
-using MonoDevelop.Ide;
using System;
using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Net.Sockets;
+using MonoDevelop.Core;
+using MonoDevelop.Core.Execution;
namespace MonoDevelop.DotNetCore
{
@@ -56,52 +52,8 @@ namespace MonoDevelop.DotNetCore
dotNetCoreCommand.WorkingDirectory,
console,
envVariables);
- if (dotNetCoreCommand.LaunchBrowser) {
- LaunchBrowser (dotNetCoreCommand.ApplicationURL, dotNetCoreCommand.LaunchURL, process.Task).Ignore ();
- }
- return process;
- }
- public static async Task LaunchBrowser (string appUrl, string launchUrl, Task processTask)
- {
- launchUrl = launchUrl ?? "";
- Uri launchUri;
- //Check if lanuchUrl is valid absolute url and use it if it is...
- if (!Uri.TryCreate (launchUrl, UriKind.Absolute, out launchUri)) {
- //Otherwise check if appUrl is valid absolute and lanuchUrl is relative then concat them...
- Uri appUri;
- if (!Uri.TryCreate (appUrl, UriKind.Absolute, out appUri)) {
- LoggingService.LogWarning ("Failed to launch browser because invalid launch and app urls.");
- return;
- }
- if (!Uri.TryCreate (launchUrl, UriKind.Relative, out launchUri)) {
- LoggingService.LogWarning ("Failed to launch browser because invalid launch url.");
- return;
- }
- launchUri = new Uri (appUri, launchUri);
- }
-
- //Try to connect every 50ms while process is running
- while (!processTask.IsCompleted) {
- await Task.Delay (50);
- using (var tcpClient = new TcpClient ()) {
- try {
- tcpClient.Connect (launchUri.Host, launchUri.Port);
- // pause briefly to allow the server process to initialize
- await Task.Delay (TimeSpan.FromSeconds (1));
- break;
- } catch {
- }
- }
- }
-
- if (processTask.IsCompleted) {
- LoggingService.LogDebug ("Failed to launch browser because process exited before server started listening.");
- return;
- }
-
- // Process is still alive hence we succesfully connected inside loop to web server, launch browser
- IdeServices.DesktopService.ShowUrl (launchUri.AbsoluteUri);
+ return process;
}
}
} \ No newline at end of file