diff options
author | Rodrigo Moya <rodrigo.moya@xamarin.com> | 2019-07-17 18:57:19 +0300 |
---|---|---|
committer | Rodrigo Moya <rodrigo.moya@xamarin.com> | 2019-07-25 12:31:12 +0300 |
commit | c6af3e627a728356c3ae44d2c35806862feaf583 (patch) | |
tree | 01b3ceaa4ef7f8c7e2d3cfaca91e4d768290cf76 /main/src/addins | |
parent | 82107ab37be406c89d3652c1b7a2a27f7ca8710b (diff) |
[AspNetCore] Add support for browsers as execution targets
Diffstat (limited to 'main/src/addins')
3 files changed, 62 insertions, 0 deletions
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/AspNetCoreExecutionTarget.cs b/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreExecutionTarget.cs new file mode 100644 index 0000000000..2b787a3517 --- /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 + { + readonly DesktopApplication desktopApplication; + + internal AspNetCoreExecutionTarget (DesktopApplication desktopApplication) + { + this.desktopApplication = desktopApplication; + } + + public override string Name => desktopApplication.DisplayName; + + public override string Id => desktopApplication.Id; + } +} diff --git a/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreProjectExtension.cs b/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreProjectExtension.cs index ae503d3388..4c05b87f32 100644 --- a/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreProjectExtension.cs +++ b/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore/AspNetCoreProjectExtension.cs @@ -24,8 +24,10 @@ // 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 GLib; using MonoDevelop.Core; using MonoDevelop.Core.Execution; using MonoDevelop.DotNetCore; @@ -100,6 +102,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)) { |