-
Notifications
You must be signed in to change notification settings - Fork 545
[One .NET] add $(AndroidGenerateResourceDesigner) property #6224
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[One .NET] add $(AndroidGenerateResourceDesigner) property #6224
Conversation
3d1a809
to
668e52d
Compare
Fixes: dotnet#6198 When migrating Xamarin.Android binding projects to .NET 6, one difference is that `Resource.designer.cs` will be generated by .NET 6 class libraries. There is not currently a way to turn this off, if you pass: dotnet build -p:AndroidUseIntermediateDesignerFile=false Then `Resources\Resource.designer.cs` will be generated instead. There is no way to prevent this behavior, because `$(AndroidResgenFile)` defaults to this value. To solve cases where you *don't* want `Resource.designer.cs` at all: 1. Remove the `$(AndroidResgenFile)` default value. 2. Add a new `$(AndroidGenerateResourceDesigner)` MSBuild property, that seems like it will be a better name for .NET 6. 3. `$(AndroidUseIntermediateDesignerFile)` is based on `$(AndroidGenerateResourceDesigner)`. I added a test for the new property.
668e52d
to
71b87b8
Compare
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 should probably add it to this list of things Upgrade Assistant should do for converting bindings projects:
|
||
In Xamarin.Android, Java binding projects did not support generating a `Resource.designer.cs` file. | ||
Since binding projects are just class libraries in .NET 6, this file will be generated. This could | ||
be a breaking change when migrating existing projects. |
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 request for improvement: please provide an example error message. What should customers be looking for in their migrated projects to know that $(AndroidGenerateResourceDesigner)
=false should be set?
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 added two examples where Resource.designer.cs
can break.
Fixes: #6198 When migrating Xamarin.Android binding projects to .NET 6, one difference is that `Resource.designer.cs` will be generated by .NET 6 class libraries. This can result in build failures, e.g.: error CS0101: The namespace 'MyBinding' already contains a definition for 'Resource' There is not currently a way to turn this off; if you try: dotnet build -p:AndroidUseIntermediateDesignerFile=false Then `Resources\Resource.designer.cs` will be generated instead. There is no way to prevent this behavior, because `$(AndroidResgenFile)` defaults to this value. To solve cases where you *don't* want `Resource.designer.cs` at all: 1. Remove the `$(AndroidResgenFile)` default value. 2. Add a new `$(AndroidGenerateResourceDesigner)` MSBuild property, that seems like it will be a better name for .NET 6. `$(AndroidGenerateResourceDesigner)` defaults to True. 3. `$(AndroidUseIntermediateDesignerFile)` is based on `$(AndroidGenerateResourceDesigner)`. This way, if a Xamarin.Android binding project is migrated to .NET 6, the binding project can set `$(AndroidGenerateResourceDesigner)`=False to prevent `Resource.designer.cs` from being generated, which may prevent build failures. I added a test and docs for the new property.
Fixes: #6198
When migrating Xamarin.Android binding projects to .NET 6, one
difference is that
Resource.designer.cs
will be generated by .NET 6class libraries.
There is not currently a way to turn this off, if you pass:
Then
Resources\Resource.designer.cs
will be generated instead. Thereis no way to prevent this behavior, because
$(AndroidResgenFile)
defaults to this value.
To solve cases where you don't want
Resource.designer.cs
at all:$(AndroidResgenFile)
default value.$(AndroidGenerateResourceDesigner)
MSBuild property,that seems like it will be a better name for .NET 6.
$(AndroidUseIntermediateDesignerFile)
is based on$(AndroidGenerateResourceDesigner)
.I added a test for the new property.