-
Notifications
You must be signed in to change notification settings - Fork 695
Update Aspire.AppHost.Sdk to support simpler file-based app AppHosts #11445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
153e3a3
65f8586
8c4ba11
c584212
2d2d0cb
c97e648
9dfa9e9
112e4e9
1c48da7
d4dde9f
96e0065
7e3c467
979496f
46b90c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,9 +1,20 @@ | ||||||||||||
<Project> | ||||||||||||
<PropertyGroup> | ||||||||||||
<AspireHostingSDKVersion>@VERSION@</AspireHostingSDKVersion> | ||||||||||||
<!-- Do not import the workload targets as this project is instead using | ||||||||||||
the Aspire.AppHost.Sdk --> | ||||||||||||
<!-- Do not import the workload targets as this project is instead using the Aspire.AppHost.Sdk --> | ||||||||||||
<SkipAspireWorkloadManifest>true</SkipAspireWorkloadManifest> | ||||||||||||
<IsAspireHost>true</IsAspireHost> | ||||||||||||
<PublishAot>false</PublishAot> | ||||||||||||
<PublishTrimmed>false</PublishTrimmed> | ||||||||||||
<EnableAotAnalyzer>false</EnableAotAnalyzer> | ||||||||||||
<EnableTrimAnalyzer>false</EnableTrimAnalyzer> | ||||||||||||
<EnableSingleFileAnalyzer>false</EnableSingleFileAnalyzer> | ||||||||||||
Comment on lines
+10
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These property defaults are duplicated in both Sdk.in.props (lines 7-11) and in the DisablePublishAotForAspireHost target in Sdk.in.targets (lines 56-60). This duplication could lead to inconsistencies. Consider consolidating these settings in one location, preferably in the target where they can be conditionally applied.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, doing it in both places until dotnet/sdk#50885 is merged and flows through to rc.2 builds. |
||||||||||||
<_ImportMicrosoftNETSdkFromAspireSdk>false</_ImportMicrosoftNETSdkFromAspireSdk> | ||||||||||||
</PropertyGroup> | ||||||||||||
|
||||||||||||
<PropertyGroup Condition=" '$(UsingMicrosoftNETSdk)' == '' "> | ||||||||||||
<_ImportMicrosoftNETSdkFromAspireSdk>true</_ImportMicrosoftNETSdkFromAspireSdk> | ||||||||||||
</PropertyGroup> | ||||||||||||
|
||||||||||||
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" Condition=" '$(_ImportMicrosoftNETSdkFromAspireSdk)' == 'true' " /> | ||||||||||||
</Project> |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,6 +6,8 @@ | |||||
This means they cannot be overridden in the csproj, and may cause ordering issues, particularly StaticWebAssets. | ||||||
--> | ||||||
|
||||||
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" Condition=" '$(_ImportMicrosoftNETSdkFromAspireSdk)' == 'true' " /> | ||||||
|
||||||
<ItemGroup> | ||||||
<ProjectCapability Include="DynamicFileNesting" /> | ||||||
<ProjectCapability Include="DynamicFileNestingEnabled" /> | ||||||
|
@@ -49,11 +51,35 @@ | |||||
<AspireRidToolExecutable>$(AspireRidToolDirectory)Aspire.RuntimeIdentifier.Tool.dll</AspireRidToolExecutable> | ||||||
</PropertyGroup> | ||||||
|
||||||
<Target Name="DisablePublishAotForAspireHost" BeforeTargets="_ComputeToolPackInputsToProcessFrameworkReferences;_CollectTargetFrameworkForTelemetry;ProcessFrameworkReferences;Restore;CollectPackageReferences" Condition="'$(IsAspireHost)' == 'true' and '$(DisableAspirePublishAotDefaults)' != 'true'"> | ||||||
|
<Target Name="DisablePublishAotForAspireHost" BeforeTargets="_ComputeToolPackInputsToProcessFrameworkReferences;_CollectTargetFrameworkForTelemetry;ProcessFrameworkReferences;Restore;CollectPackageReferences" Condition="'$(IsAspireHost)' == 'true' and '$(DisableAspirePublishAotDefaults)' != 'true'"> | |
<Target Name="SetAspireHostAotDefaults" BeforeTargets="_ComputeToolPackInputsToProcessFrameworkReferences;_CollectTargetFrameworkForTelemetry;ProcessFrameworkReferences;Restore;CollectPackageReferences" Condition="'$(IsAspireHost)' == 'true' and '$(DisableAspirePublishAotDefaults)' != 'true'"> |
Copilot uses AI. Check for mistakes.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a part of me that wants to try and trim this dependency list - e.g. Restore is implied by CollectPackageReferences, so it could be safe to drop Restore directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intent is for this to go away completely once dotnet/sdk#50885 is in anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this target if these are defined in Sdk.props already statically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because file-based apps resets the PublishAot
property (and thus everything that is evaluated off of its value) directly in the virtual project today, so setting it in our props gets overwritten. Doing it in this target is required to ensure it overrides what is set in the project. This whole target will be removed once dotnet run
is fixed to only set the implicit project-level stuff if a value isn't already explicitly set (dotnet/sdk#50885).
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I don't like about this change, is that it may cause people to remove the PackageReference from their project, and therefore never finding out if there is a newer version of Aspire given Msbuild SDKs don't have update notifications. If possible, I'd also condition this to only happen for file-based apps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have to advertise it for now and the templates aren't being changed. Plus we have aspire update
(assuming that still works 😄). If we're really super concerned about this, we can limit this to file-based AppHosts only.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: why do you need to check PackageVersion too? Even if using CPM, wouldn't we want to do this even if there was a PackageVersion for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's copilot being helpful 😄
I think it's safe to remove the check for PackageVersion like you say.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although the challenge there is, if using CPM, we don't want to implicitly add the package with a version right? Because that version should now be controlled by CPM, not the PackageReference we add. Or does the IsImplicitlyDefined="true"
effectively turn off CPM for that PackageReference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, when you mark the package as implicitly defined then you can pass a version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of setting all of these it may be easier to set
IsAotCompatible
andIsTrimmable
to false - these are an implicit condition of all 3 of the analyzers, and they also tie into disabling the ProjectCapability Items you remove later on:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think still need to set these explicitly don't I because they'll be set an evaluation due to the file-based apps virtual project setting
PublishAot
to true?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also AppHost projects aren't publishable so the publish targets shouldn't matter in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mm not sure I love setting these in the SDK, where other projects that are not file-based apps would be impacted. Is there a way to fix this via the virtual project somehow? For instance, if it sees that the aspire sdk is set then set these to false inside the virtual project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm not a fan of hard-coding stuff like that in file-based apps directly, that's backwards :)
SDKs should be able to impart changes on projects that reference them, that's not an issue. This specific implementation of doing it in the targets is a temp workaround for file-based apps which we can remove once that's fixed. Then we'll just be setting the default values of these in our
Sdk.in.props
file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a property that we can chain of only defined in virtual projects so we can add a condition to these? If not, I think at the very least we should add conditions to all of these to check if they were not already defined (meaning only set them if they are not set already)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This specifically won't work because of where they have to run, that's the issue.
We can condition this so that it only applies to file-based apps (there's a property) if we really want to isolate it, but I'm not convinced it matters. What's the concern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put the other way - are there actual valid use cases for an Aspire AppHost to be trimmed/AOT? If not, why even allow it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are not, it's dev time only and we block publishing.