Skip to content

Commit

Permalink
Correctly check for .NET Core before creating config files. (#818)
Browse files Browse the repository at this point in the history
* Small refactoring of the .NET Core check.

* Ensuring licenses.
  • Loading branch information
ivannaranjo authored Oct 3, 2017
1 parent 182b8bd commit 3398931
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
<Compile Include="GkeDeployment.cs" />
<Compile Include="GkeDeploymentResult.cs" />
<Compile Include="IParsedProject.cs" />
<Compile Include="IParsedProjectExtensions.cs" />
<Compile Include="IToolsPathProvider.cs" />
<Compile Include="KnownProjectTypes.cs" />
<Compile Include="NetCoreAppUtils.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2017 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GoogleCloudExtension.Deployment
{
/// <summary>
/// Useful checks for projects.
/// </summary>
public static class IParsedProjectExtensions
{
/// <summary>
/// Determines if the given project is a .NET Core project or not.
/// </summary>
/// <param name="project">The project to check.</param>
/// <returns>Returns true if the project is a .NET Core project, false otherwise.</returns>
public static bool IsAspNetCoreProject(this IParsedProject project)
=> project.ProjectType == KnownProjectTypes.NetCoreWebApplication1_0 ||
project.ProjectType == KnownProjectTypes.NetCoreWebApplication1_1 ||
project.ProjectType == KnownProjectTypes.NetCoreWebApplication2_0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private void OnBeforeQueryStatus(object sender, EventArgs e)

// Ensure that the menu entry is only available for ASP.NET Core projects.
var selectedProject = SolutionHelper.CurrentSolution.SelectedProject;
if (selectedProject == null || !PublishDialogWindow.CanPublish(selectedProject))
if (selectedProject == null || !selectedProject.IsAspNetCoreProject())
{
menuCommand.Visible = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private IEnumerable<Choice> GetChoicesForCurrentProject()
Name = Resources.PublishDialogChoiceStepAppEngineFlexName,
Command = new ProtectedCommand(
OnAppEngineChoiceCommand,
canExecuteCommand: IsSupportedNetCoreProject(_dialog.Project)),
canExecuteCommand: _dialog.Project.IsAspNetCoreProject()),
Icon = s_appEngineIcon.Value,
ToolTip = Resources.PublishDialogChoiceStepAppEngineToolTip
},
Expand All @@ -78,7 +78,7 @@ private IEnumerable<Choice> GetChoicesForCurrentProject()
Name = Resources.PublishDialogChoiceStepGkeName,
Command = new ProtectedCommand(
OnGkeChoiceCommand,
canExecuteCommand:IsSupportedNetCoreProject(_dialog.Project)),
canExecuteCommand:_dialog.Project.IsAspNetCoreProject()),
Icon = s_gkeIcon.Value,
ToolTip = Resources.PublishDialogChoiceStepGkeToolTip
},
Expand Down Expand Up @@ -133,10 +133,5 @@ public static IPublishDialogStep CreateStep()

return viewModel;
}

private static bool IsSupportedNetCoreProject(IParsedProject project)
=> project.ProjectType == KnownProjectTypes.NetCoreWebApplication1_0 ||
project.ProjectType == KnownProjectTypes.NetCoreWebApplication1_1 ||
project.ProjectType == KnownProjectTypes.NetCoreWebApplication2_0;
}
}

0 comments on commit 3398931

Please sign in to comment.