Skip to content
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

Do not include Maui.InTree.targets for an AspNet.Core project #23246

Conversation

simonrozsival
Copy link
Member

Description of Change

After we introduced the Binding Source Generator, it started generating code also in the Essentials.Sample.Server.WebAuthenticator.csproj which is an ASP.NET Core server and shouldn't include the analzyer:

D:\a\_work\1\s\artifacts\obj\Essentials.Sample.Server.WebAuthenticator\Release\net9.0\Microsoft.Maui.Controls.BindingSourceGen\Microsoft.Maui.Controls.BindingSourceGen.BindingSourceGenerator\GeneratedBindingInterceptorsCommon.g.cs(40,39): error CS0246: The type or namespace name 'BindingMode' could not be found (are you missing a using directive or an assembly reference?) [D:\a\_work\1\s\src\Essentials\samples\Sample.Server.WebAuthenticator\Essentials.Sample.Server.WebAuthenticator.csproj]
D:\a\_work\1\s\artifacts\obj\Essentials.Sample.Server.WebAuthenticator\Release\net9.0\Microsoft.Maui.Controls.BindingSourceGen\Microsoft.Maui.Controls.BindingSourceGen.BindingSourceGenerator\GeneratedBindingInterceptorsCommon.g.cs(40,57): error CS0246: The type or namespace name 'BindableProperty' could not be found (are you missing a using directive or an assembly reference?) [D:\a\_work\1\s\src\Essentials\samples\Sample.Server.WebAuthenticator\Essentials.Sample.Server.WebAuthenticator.csproj]
D:\a\_work\1\s\artifacts\obj\Essentials.Sample.Server.WebAuthenticator\Release\net9.0\Microsoft.Maui.Controls.BindingSourceGen\Microsoft.Maui.Controls.BindingSourceGen.BindingSourceGenerator\GeneratedBindingInterceptorsCommon.g.cs(47,39): error CS0246: The type or namespace name 'BindingMode' could not be found (are you missing a using directive or an assembly reference?) [D:\a\_work\1\s\src\Essentials\samples\Sample.Server.WebAuthenticator\Essentials.Sample.Server.WebAuthenticator.csproj]

It seems that the problem is that we're including Maui.InTree.targets for non-MAUI projects in src/Essentials/samples/Directory.Build.targets (see history of that file). I don't understand why we needed to import that targets file, it doesn't seem to be necessary to build the ASP.NET Core project.

/cc @jonathanpeppers @PureWeen @mattleibow @StephaneDelcroix

@simonrozsival simonrozsival requested a review from a team as a code owner June 25, 2024 15:59
@mattleibow
Copy link
Member

It is needed for the essentials maui app sample in there. However, maybe we can just put the targets file in the app folder instead?

@simonrozsival
Copy link
Member Author

simonrozsival commented Jun 25, 2024

@mattleibow I see. The $(UseMaui)' != 'true' condition confused me. Now that I looked closely I noticed that the sample MAUI app doesn't set UseMaui=true. I will move the file.

EDIT: so the UseMaui property is set in the Directory.Build.props based on the value of the UseWorkload property. Now I'm less confident in making this change and I will need to revisit this tomorrow.

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

Yes, it doesn't seem like this project would use UseMaui=true, so you shouldn't need Maui.InTree.targets.

@simonrozsival simonrozsival merged commit 80771be into dotnet:net9.0 Jun 27, 2024
48 checks passed
@simonrozsival simonrozsival deleted the fix-essentials-sample-webserver-project branch June 27, 2024 10:15
@github-actions github-actions bot locked and limited conversation to collaborators Jul 28, 2024
@samhouts samhouts added the fixed-in-net9.0-nightly This may be available in a nightly release! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed-in-net9.0-nightly This may be available in a nightly release!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants