Skip to content

Commit 49c8994

Browse files
authored
Merge pull request #1126 from JetBrains/rabdrakhmanov/improve-azure-project-detection
Improve Azure Function project detection
2 parents 39f7e87 + c341897 commit 49c8994

File tree

9 files changed

+104
-187
lines changed

9 files changed

+104
-187
lines changed

PluginsAndFeatures/azure-toolkit-for-rider/CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
### Changed
88

9+
- Unify logic to detect Azure Function projects by using `AzureFunctionsVersion` MSBuild property ([RIDER-131333](https://youtrack.jetbrains.com/issue/RIDER-131333))
10+
11+
## [4.6.0] - 2025-10-21
12+
13+
### Changed
14+
915
- Support for Rider 2025.3 EAP 6
1016

1117
## [4.5.5] - 2025-10-09
@@ -365,7 +371,8 @@
365371
- Reimplement Azure Functions Core Tools integration
366372
- Reimplement Azure Functions templates
367373

368-
[Unreleased]: https://github.com/JetBrains/azure-tools-for-intellij/compare/4.5.5...HEAD
374+
[Unreleased]: https://github.com/JetBrains/azure-tools-for-intellij/compare/4.6.0...HEAD
375+
[4.6.0]: https://github.com/JetBrains/azure-tools-for-intellij/compare/4.5.5...4.6.0
369376
[4.5.5]: https://github.com/JetBrains/azure-tools-for-intellij/compare/4.5.4...4.5.5
370377
[4.5.4]: https://github.com/JetBrains/azure-tools-for-intellij/compare/4.5.3...4.5.4
371378
[4.5.3]: https://github.com/JetBrains/azure-tools-for-intellij/compare/v4.5.2...v4.5.3

PluginsAndFeatures/azure-toolkit-for-rider/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pluginGroup = com.jetbrains
44
pluginName = Azure Toolkit for Rider
55
pluginRepositoryUrl = https://github.com/JetBrains/azure-tools-for-intellij
66
# SemVer format -> https://semver.org
7-
pluginVersion = 4.6.0
7+
pluginVersion = 4.6.1
88

99
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
1010
pluginSinceBuild = 253

PluginsAndFeatures/azure-toolkit-for-rider/src/dotnet/ReSharper.Azure/Azure.Daemon/RunMarkers/FunctionAppRunMarkerProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2018-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the MIT license.
22

33
using JetBrains.Application.Settings;
4-
using JetBrains.ReSharper.Azure.Project.FunctionApp;
4+
using JetBrains.ProjectModel;
55
using JetBrains.ReSharper.Azure.Psi.FunctionApp;
66
using JetBrains.ReSharper.Feature.Services.Daemon;
77
using JetBrains.ReSharper.Psi;
@@ -26,7 +26,7 @@ public void CollectRunMarkers(IFile file, IContextBoundSettingsStore settings, I
2626

2727
var project = file.GetProject();
2828
if (project == null || !project.IsValid()) return;
29-
if (!project.IsAzureFunctionsProject()) return;
29+
if (!project.IsAzureFunctionProject()) return;
3030

3131
foreach (var declaration in CachedDeclarationsCollector.Run<IMethodDeclaration>(csharpFile))
3232
{

PluginsAndFeatures/azure-toolkit-for-rider/src/dotnet/ReSharper.Azure/Azure.Intellisense/FunctionApp/LiveTemplates/Scope/AzureProjectScopeProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public AzureProjectScopeProvider()
3939
public override IEnumerable<ITemplateScopePoint> ProvideScopePoints(TemplateAcceptanceContext context)
4040
{
4141
var project = context.GetProject();
42-
if (project == null || !project.IsAzureFunctionsProject()) yield break;
42+
if (project == null || !project.IsAzureFunctionProject()) yield break;
4343

4444
yield return new InAzureFunctionsProject();
4545

PluginsAndFeatures/azure-toolkit-for-rider/src/dotnet/ReSharper.Azure/Azure.Project/Dockerfile/AzureFunctionsProjectDockerfileContentGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class AzureFunctionsProjectDockerfileContentGenerator(ILogger logger) : I
1919
{
2020
public int Priority => 10;
2121

22-
public bool IsApplicable(IProject project) => project.IsAzureFunctionsProject();
22+
public bool IsApplicable(IProject project) => project.IsAzureFunctionProject();
2323

2424
public string Generate(
2525
IProject project,

PluginsAndFeatures/azure-toolkit-for-rider/src/dotnet/ReSharper.Azure/Azure.Project/FunctionApp/FunctionAppProjectDetector.cs

Lines changed: 0 additions & 174 deletions
This file was deleted.

PluginsAndFeatures/azure-toolkit-for-rider/src/dotnet/ReSharper.Azure/Azure.Project/FunctionApp/FunctionAppProjectTechnologyProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class FunctionAppProjectTechnologyProvider : IProjectTechnologyAnalyticsP
1212
{
1313
public IEnumerable<string> GetProjectTechnology(IProject project)
1414
{
15-
if (project.IsAzureFunctionsProject())
15+
if (project.IsAzureFunctionProject())
1616
{
1717
yield return "Azure Function";
1818
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2018-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the MIT license.
2+
3+
using JetBrains.ProjectModel;
4+
using JetBrains.ProjectModel.Assemblies.Interfaces;
5+
using JetBrains.ProjectModel.NuGet.Packaging;
6+
7+
namespace JetBrains.ReSharper.Azure.Project.FunctionApp;
8+
9+
/// <summary>
10+
/// Provides methods for detecting the worker model associated with an Azure Functions project
11+
/// based on installed NuGet package references.
12+
/// </summary>
13+
public static class FunctionProjectWorkerModelDetector
14+
{
15+
private static readonly NugetId DefaultWorkerNuGetId = new("Microsoft.NET.Sdk.Functions");
16+
private static readonly NugetId IsolatedWorkerNuGetId = new("Microsoft.Azure.Functions.Worker.Sdk");
17+
18+
/// <summary>
19+
/// Determines if the given project has a default worker NuGet package reference installed.
20+
/// </summary>
21+
/// <param name="project">The project to check for the default worker NuGet package reference.</param>
22+
/// <returns>True if the default worker NuGet package reference is installed; otherwise, false.</returns>
23+
public static bool HasDefaultWorkerPackageReference(this IProject project)
24+
{
25+
var checker = project.GetComponent<NuGetInstalledPackageChecker>();
26+
return checker.IsPackageInstalled(project, DefaultWorkerNuGetId.ID);
27+
}
28+
29+
/// <summary>
30+
/// Determines if the given project has an isolated worker NuGet package reference installed.
31+
/// </summary>
32+
/// <param name="project">The project to check for the isolated worker NuGet package reference.</param>
33+
/// <returns>True if the isolated worker NuGet package reference is installed; otherwise, false.</returns>
34+
public static bool HasIsolatedWorkerPackageReference(this IProject project)
35+
{
36+
var checker = project.GetComponent<NuGetInstalledPackageChecker>();
37+
return checker.IsPackageInstalled(project, IsolatedWorkerNuGetId.ID);
38+
}
39+
40+
/// <summary>
41+
/// Determines the worker model for the specified Azure Functions project based on the installed NuGet package references.
42+
/// </summary>
43+
/// <param name="project">The Azure Functions project to analyse for worker model detection.</param>
44+
/// <returns>The detected <see cref="FunctionProjectWorkerModel"/> indicating the worker model of the project.</returns>
45+
public static FunctionProjectWorkerModel GetFunctionProjectWorkerModel(this IProject project)
46+
{
47+
if (HasIsolatedWorkerPackageReference(project))
48+
return FunctionProjectWorkerModel.Isolated;
49+
else if (HasDefaultWorkerPackageReference(project))
50+
return FunctionProjectWorkerModel.Default;
51+
else
52+
return FunctionProjectWorkerModel.Unknown;
53+
}
54+
}

PluginsAndFeatures/azure-toolkit-for-rider/src/dotnet/ReSharper.Azure/Azure.Project/RunnableProject/AzureFunctionsRunnableProjectProvider.cs

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
using System.Collections.Generic;
44
using JetBrains.Application.Parts;
5+
using JetBrains.Application.Threading;
56
using JetBrains.ProjectModel;
6-
using JetBrains.ReSharper.Azure.Project.FunctionApp;
7+
using JetBrains.ProjectModel.Properties;
8+
using JetBrains.ProjectModel.Properties.Managed;
79
using JetBrains.ReSharper.Features.Running;
810
using JetBrains.Rider.Model;
911
using JetBrains.Util;
@@ -22,15 +24,43 @@ public class AzureFunctionsRunnableProjectProvider(ILogger logger) : IRunnablePr
2224
return null;
2325
}
2426

25-
var projectOutputs = project.GetAzureFunctionsCompatibleProjectOutputs(out var problems, logger);
26-
27-
if (projectOutputs.IsEmpty())
27+
if (!project.IsAzureFunctionProject())
2828
{
29-
logger.Trace("No project output was found, return null");
29+
logger.Trace("Project is not an Azure Function project, return null");
3030
return null;
3131
}
3232

33-
logger.Trace($"AzureFunctionsRunnableProjectProvider returned RunnableProject {fullName}");
33+
var projectOutputs = new List<ProjectOutput>();
34+
string? problems = null;
35+
36+
foreach (var tfm in project.TargetFrameworkIds)
37+
{
38+
var configuration = project.ProjectProperties.TryGetConfiguration<IManagedProjectConfiguration>(tfm);
39+
if (configuration == null || (configuration.OutputType != ProjectOutputType.LIBRARY &&
40+
configuration.OutputType != ProjectOutputType.CONSOLE_EXE))
41+
{
42+
logger.Trace($"Project OutputType = {configuration?.OutputType}, skip configuration");
43+
continue;
44+
}
45+
46+
var projectOutputPath = project.GetOutputFilePath(tfm);
47+
// Azure Functions host needs the tfm folder, not the bin folder
48+
var workingDirectoryPath = projectOutputPath.Directory
49+
.NormalizeSeparators(FileSystemPathEx.SeparatorStyle.Unix)
50+
.TrimFromEnd("/bin");
51+
52+
var projectOutput = new ProjectOutput(
53+
tfm.ToRdTargetFrameworkInfo(),
54+
projectOutputPath.NormalizeSeparators(FileSystemPathEx.SeparatorStyle.Unix),
55+
["host", "start", "--pause-on-error"],
56+
workingDirectoryPath,
57+
string.Empty,
58+
null,
59+
[]
60+
);
61+
62+
projectOutputs.Add(projectOutput);
63+
}
3464

3565
return new Rider.Model.RunnableProject(
3666
name,

0 commit comments

Comments
 (0)