You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this is a question how I am supposed to properly set up projects when using a) minimal api web project and b) minimal api request delegates in referenced library projects.
I have the following scenario:
ASP.NET Core minimal API webhost project
this has <PublishAot>true</PublishAot> in csproj
several library projects which contain minimal api registrations (MapX) and request delegates
these projects are setup like:
Sdk="Microsoft.NET.Sdk.Web"
<OutputType>Library</OutputType>
neither PublishAot, PublishTrimmed, EnableRequestDelegateGenerator, EnableConfigurationBindingGenerator set in csproj
When AOT publishing, due to the setup of these csprojs, the request delegate source generator only runs on the main ASP.NET Core webhost project, but not on any of the library projects which contain the minimal api delegates. This leads to run time errors.
When enabling any of the properties (PublishAot, PublishTrimmed, EnableRequestDelegateGenerator ...) on each of the library projects, everything works as expected.
What is the recommended pattern if I want to host my minimal api request handling logic in separate projects? Is that recommended at all? Am I supposed to set PublishAot on every library project (this may alter the run-time behavior of the library). The .NET AOT analyzers can also be triggered on library projects using <IsAotCompatible>true</ ... this does not trigger the minimal api source gen.
General .NET AOT question: if I have a executable project which uses PublishAot, am I supposed to also set <PublishAot>true</PublishAot> on any referenced library project under my control? Since PublishTrimmed and PublishAot use completely separate ways of "trimming", am I supposed to/is it recommended to always use PublishTrimmed when using PublishAot?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
this is a question how I am supposed to properly set up projects when using a) minimal api web project and b) minimal api request delegates in referenced library projects.
I have the following scenario:
<PublishAot>true</PublishAot>
in csprojMapX
) and request delegatesSdk="Microsoft.NET.Sdk.Web"
<OutputType>Library</OutputType>
PublishAot, PublishTrimmed, EnableRequestDelegateGenerator, EnableConfigurationBindingGenerator
set in csprojWhen AOT publishing, due to the setup of these csprojs, the request delegate source generator only runs on the main ASP.NET Core webhost project, but not on any of the library projects which contain the minimal api delegates. This leads to run time errors.
When enabling any of the properties (
PublishAot, PublishTrimmed, EnableRequestDelegateGenerator ...
) on each of the library projects, everything works as expected.What is the recommended pattern if I want to host my minimal api request handling logic in separate projects? Is that recommended at all? Am I supposed to set
PublishAot
on every library project (this may alter the run-time behavior of the library). The .NET AOT analyzers can also be triggered on library projects using<IsAotCompatible>true</
... this does not trigger the minimal api source gen.General .NET AOT question: if I have a executable project which uses
PublishAot
, am I supposed to also set<PublishAot>true</PublishAot>
on any referenced library project under my control? Since PublishTrimmed and PublishAot use completely separate ways of "trimming", am I supposed to/is it recommended to always use PublishTrimmed when using PublishAot?Thanks for recommendations.
Beta Was this translation helpful? Give feedback.
All reactions