Skip to content

Use UsingMSBuildSDKSystemWeb property to avoid ASPIRE004 warning. #595

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

CZEMacLeod
Copy link
Contributor

Cleaner way of handing APIRE004 issue instead of supressing the warning.

This sets the property _IsExecutable on projects based on MSBuild.SDK.SystemWeb when calling the GetTargetFrameworksWithPlatformForSingleTargetFramework target.

This target is used in the call to get AdditionalPropertiesFromProject which is then used in the GetNonExecutableReferences task which returns project references which have this set to false.
_ValidateAspireHostProjectResources then triggers the ASPIRE004 warning for each such project.

https://github.com/dotnet/aspire/blob/ad77802ef553c1e146512588ab05d08453d7e381/src/Aspire.Hosting.AppHost/build/Aspire.Hosting.AppHost.in.targets#L115-L183

This does require MSBuild.SDK.SystemWeb >= 4.0.97 but global.json sets version 4.0.104

Rather than supressing the warning, set the property `_IsExecutable` on projects based on `MSBuild.SDK.SystemWeb` when calling the `GetTargetFrameworksWithPlatformForSingleTargetFramework` property which is used in the call to get `AdditionalPropertiesFromProject` which is used in the `GetNonExecutableReferences` task which returns project references which have this set to false.
`_ValidateAspireHostProjectResources` then triggers the `ASPIRE004` warning for each such project.
@twsouthwick
Copy link
Member

Thanks! Any thoughts on merging it into the MSBuild.SDK.SystemWeb project?

Copy link
Member

@twsouthwick twsouthwick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a spelling issue - looks good once that's fixed

@CZEMacLeod
Copy link
Contributor Author

I have considered this - even just adding the property _IsExecutable globally in the SDK. I'm just not sure what effect that might have elsewhere.
I don't know if the MSBuild task in _ValidateAspireHostProjectResources passes any properties that could be used to detect that the GetTargetFrameworksWithPlatformForSingleTargetFramework was called from an aspire host project.
If so, it would be easier to selectively enable it and I'd be happy to include it in 'MSBuild.SDK.SystemWeb'.

Fix spelling mistakes
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.

2 participants