Skip to content
This repository was archived by the owner on May 16, 2025. It is now read-only.

Commit 3398931

Browse files
authored
Correctly check for .NET Core before creating config files. (#818)
* Small refactoring of the .NET Core check. * Ensuring licenses.
1 parent 182b8bd commit 3398931

File tree

4 files changed

+43
-8
lines changed

4 files changed

+43
-8
lines changed

GoogleCloudExtension/GoogleCloudExtension.Deployment/GoogleCloudExtension.Deployment.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
<Compile Include="GkeDeployment.cs" />
9595
<Compile Include="GkeDeploymentResult.cs" />
9696
<Compile Include="IParsedProject.cs" />
97+
<Compile Include="IParsedProjectExtensions.cs" />
9798
<Compile Include="IToolsPathProvider.cs" />
9899
<Compile Include="KnownProjectTypes.cs" />
99100
<Compile Include="NetCoreAppUtils.cs" />
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2017 Google Inc. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
using System;
16+
using System.Collections.Generic;
17+
using System.Diagnostics;
18+
using System.Linq;
19+
using System.Text;
20+
using System.Threading.Tasks;
21+
22+
namespace GoogleCloudExtension.Deployment
23+
{
24+
/// <summary>
25+
/// Useful checks for projects.
26+
/// </summary>
27+
public static class IParsedProjectExtensions
28+
{
29+
/// <summary>
30+
/// Determines if the given project is a .NET Core project or not.
31+
/// </summary>
32+
/// <param name="project">The project to check.</param>
33+
/// <returns>Returns true if the project is a .NET Core project, false otherwise.</returns>
34+
public static bool IsAspNetCoreProject(this IParsedProject project)
35+
=> project.ProjectType == KnownProjectTypes.NetCoreWebApplication1_0 ||
36+
project.ProjectType == KnownProjectTypes.NetCoreWebApplication1_1 ||
37+
project.ProjectType == KnownProjectTypes.NetCoreWebApplication2_0;
38+
}
39+
}

GoogleCloudExtension/GoogleCloudExtension/GenerateConfigurationCommand/GenerateConfigurationContextMenuCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private void OnBeforeQueryStatus(object sender, EventArgs e)
162162

163163
// Ensure that the menu entry is only available for ASP.NET Core projects.
164164
var selectedProject = SolutionHelper.CurrentSolution.SelectedProject;
165-
if (selectedProject == null || !PublishDialogWindow.CanPublish(selectedProject))
165+
if (selectedProject == null || !selectedProject.IsAspNetCoreProject())
166166
{
167167
menuCommand.Visible = false;
168168
}

GoogleCloudExtension/GoogleCloudExtension/PublishDialogSteps/ChoiceStep/ChoiceStepViewModel.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ private IEnumerable<Choice> GetChoicesForCurrentProject()
6969
Name = Resources.PublishDialogChoiceStepAppEngineFlexName,
7070
Command = new ProtectedCommand(
7171
OnAppEngineChoiceCommand,
72-
canExecuteCommand: IsSupportedNetCoreProject(_dialog.Project)),
72+
canExecuteCommand: _dialog.Project.IsAspNetCoreProject()),
7373
Icon = s_appEngineIcon.Value,
7474
ToolTip = Resources.PublishDialogChoiceStepAppEngineToolTip
7575
},
@@ -78,7 +78,7 @@ private IEnumerable<Choice> GetChoicesForCurrentProject()
7878
Name = Resources.PublishDialogChoiceStepGkeName,
7979
Command = new ProtectedCommand(
8080
OnGkeChoiceCommand,
81-
canExecuteCommand:IsSupportedNetCoreProject(_dialog.Project)),
81+
canExecuteCommand:_dialog.Project.IsAspNetCoreProject()),
8282
Icon = s_gkeIcon.Value,
8383
ToolTip = Resources.PublishDialogChoiceStepGkeToolTip
8484
},
@@ -133,10 +133,5 @@ public static IPublishDialogStep CreateStep()
133133

134134
return viewModel;
135135
}
136-
137-
private static bool IsSupportedNetCoreProject(IParsedProject project)
138-
=> project.ProjectType == KnownProjectTypes.NetCoreWebApplication1_0 ||
139-
project.ProjectType == KnownProjectTypes.NetCoreWebApplication1_1 ||
140-
project.ProjectType == KnownProjectTypes.NetCoreWebApplication2_0;
141136
}
142137
}

0 commit comments

Comments
 (0)