Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 18, 2025

The generator auto-detects project type by checking for Microsoft.Azure.Functions.Worker.Extensions.DurableTask in referenced assemblies. This fails when transitive dependencies include Functions packages but the project targets Durable Task Worker/Scheduler, causing incorrect code generation (Functions triggers instead of AddAllGeneratedTasks).

Changes

  • New MSBuild property: DurableTaskGeneratorProjectType overrides auto-detection

    • Standalone: Forces standalone Durable Task Worker mode
    • Functions: Forces Azure Functions mode
    • Auto or omitted: Uses existing auto-detection
  • Implementation: Read property via AnalyzerConfigOptionsProvider in generator initialization, check explicit config before falling back to assembly detection

  • Tests: 7 tests covering override scenarios and fallback behavior

Usage

<PropertyGroup>
  <!-- Force Standalone mode despite Functions dependencies -->
  <DurableTaskGeneratorProjectType>Standalone</DurableTaskGeneratorProjectType>
</PropertyGroup>

Generates AddAllGeneratedTasks() registration method:

builder.Services.AddDurableTaskWorker(b => 
{
    b.AddTasks(r => r.AddAllGeneratedTasks());
});
Original prompt

This section details on the original issue you should resolve

<issue_title>Generator needs explicit project type configuration option</issue_title>
<issue_description>I am attempting to use the code as seen here:
https://github.com/microsoft/durabletask-dotnet/blob/main/samples/WebAPI/Program.cs

builder.Services.AddDurableTaskWorker(builder =>
{
    builder.AddTasks(r => r.AddAllGeneratedTasks());
});

However, because I have an indirect dependency (not used!) importing packages relating to Durable Functions the code generation does not generate the AddAllGeneratedTasks method. The generated code is targeting functions, when instead I am trying to use App Service.

Problem:
The code generator analyzes all imported packages and generates code targeting Azure Functions if a Functions related dependency is found. This is even true for unused transitive dependencies.

Request:
Provide an explicit option for setting the generator output project type (e.g. via Property in the csproj file)</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits December 18, 2025 11:33
- Add support for MSBuild property DurableTaskGeneratorProjectType
- Support values: DurableFunctions, Worker, DurableTaskScheduler, Auto
- Add comprehensive unit tests for all configuration scenarios
- All 46 generator tests passing

Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Copilot AI changed the title [WIP] Add explicit project type configuration option for generator Add explicit project type configuration for DurableTask source generator Dec 18, 2025
Copilot AI requested a review from YunchuWang December 18, 2025 11:44
@YunchuWang
Copy link
Member

@copilot update Worker/DurableTaskScheduler/DurableTaskWorker: Forces Worker mode
DurableFunctions/Functions/AzureFunctions: Forces Functions mode

to two modes, functions and standalone only.

…odes only

- Changed from multiple naming variations to two clear modes: "Functions" and "Standalone"
- Updated generator code to only accept "Functions" or "Standalone" (plus "Auto")
- Updated documentation to reflect simplified configuration
- Updated all tests to use new naming convention
- Reduced from 8 to 7 tests by consolidating similar scenarios

Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 18, 2025

@copilot update Worker/DurableTaskScheduler/DurableTaskWorker: Forces Worker mode
DurableFunctions/Functions/AzureFunctions: Forces Functions mode

...

Updated in commit cbdc3b9. The configuration now uses two modes:

  • Functions: Forces generation of Azure Functions-specific code
  • Standalone: Forces generation of standalone Durable Task Worker code

All tests updated and passing (45 total).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generator needs explicit project type configuration option

2 participants