-
Notifications
You must be signed in to change notification settings - Fork 524
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
"extern alias" added to auto generated Resource.designer.cs causes syntax errors #4542
Comments
I think I know the problem. One of the Aliases is
I think we might need to skip an alias if it is global otherwise we get this error
To work around it, you can remove the |
@dellis1972 Thanks for the response. You're right that I think you are right that the But beyond that, and in my perhaps unsolicited opinion, it seems like the Just to be clear, I'm just throwing an idea out there. If the decision is that it always adds the aliases but ignores Thanks again! |
@dellis1972 Sorry to seem impatient, but do you have a timeline on this? These two issues mono/mono#18106 are forcing me to need to update to the newest VS sooner rather than later. |
Fixes dotnet#4542 Our previous fix did not take into account that users might need to add `global` to their list of aliases in the `ProjectReferece` MetaData. This then causes the following error Error CS1681: You cannot redefine the global extern alias (CS1681) So to fix this we need to ignore the `global` entry if one is present.
Fixes dotnet#4542 Our previous fix d18c824 did not take into account that users might need to add `global` to their list of aliases in the `ProjectReferece` MetaData. This then causes the following error Error CS1681: You cannot redefine the global extern alias (CS1681) So to fix this we need to ignore the `global` entry if one is present.
I added a PR to fix this issue #4554. We will try to get this into master as soon as possible. I will check to see which release we can get this int. With regards to the Aliases and the Designer.cs file, we have no way if knowing at generation time which ones will be used in the C# code since our file is generated before the code is compiled.
We have code which calls a method in the referenced project such as
this code ensures that the library project resource id's match those in the app.
When I did that fix, I didn't realise that you could add I guess if we wanted to only use the aliases when it was required, we might check the list for |
Okay, thanks a lot. I appreciate how quickly you put the PR in. I get your point about knowing when the aliases are used and I think you are right that it would be smart to have it not emit the aliases if global is in the list. |
A little idea came to mind about a workaround you could use while waiting for the release of #4554. The idea is to add the following lines to the end of the app project .csproj file, just above the closing <PropertyGroup>
<CoreResolveReferencesDependsOn>
$(CoreResolveReferencesDependsOn);
_RemoveAliases
</CoreResolveReferencesDependsOn>
</PropertyGroup>
<Target Name="_RemoveAliases">
<ItemGroup>
<_MonoAndroidReferencePathNew Include="@(_MonoAndroidReferencePath)" RemoveMetadata="Aliases" />
<_MonoAndroidReferencePath Remove="@(_MonoAndroidReferencePath)" />
<_MonoAndroidReferencePath Include="@(_MonoAndroidReferencePathNew)" />
</ItemGroup>
</Target>
</Project> The One small caution with this approach is that the underscore prefix on Removing the |
Okay, thanks. That makes sense. If it comes to it, I will try that. Right now I have the iPhone side mostly working with the workaround for the macOS issue. My colleague is running into this same problem now, so he might want to try this workout around instead. I also just now saw an 16.5.4 update for VS. I didn't see this fix listed, but I wasn't sure if Xamarin issues would be listed under the VS release notes. Either way, thanks for working on this. |
Fixes dotnet#4542 Our previous fix d18c824 did not take into account that users might need to add `global` to their list of aliases in the `ProjectReferece` MetaData. This then causes the following error Error CS1681: You cannot redefine the global extern alias (CS1681) So to fix this we need to ignore the `global` entry if one is present.
Fixes dotnet#4542 Our previous fix d18c824 did not take into account that users might need to add `global` to their list of aliases in the `ProjectReferece` MetaData. This then causes the following error Error CS1681: You cannot redefine the global extern alias (CS1681) So to fix this we need to ignore the `global` entry if one is present.
Fixes dotnet#4542 Our previous fix d18c824 did not take into account that users might need to add `global` to their list of aliases in the `ProjectReferece` MetaData. This then causes the following error Error CS1681: You cannot redefine the global extern alias (CS1681) So to fix this we need to ignore the `global` entry if one is present.
Fixes dotnet#4542 Our previous fix d18c824 did not take into account that users might need to add `global` to their list of aliases in the `ProjectReferece` MetaData. This then causes the following error Error CS1681: You cannot redefine the global extern alias (CS1681) So to fix this we need to ignore the `global` entry if one is present.
Fixes dotnet#4542 Our previous fix d18c824 did not take into account that users might need to add `global` to their list of aliases in the `ProjectReferece` MetaData. This then causes the following error Error CS1681: You cannot redefine the global extern alias (CS1681) So to fix this we need to ignore the `global` entry if one is present.
Fixes dotnet#4542 Our previous fix d18c824 did not take into account that users might need to add `global` to their list of aliases in the `ProjectReferece` MetaData. This then causes the following error Error CS1681: You cannot redefine the global extern alias (CS1681) So to fix this we need to ignore the `global` entry if one is present.
…e. (#4554) Fixes: #4542 Our previous fix in d18c824 did not take into account that users might need to add `global` to their list of aliases in the `%(ProjectReference.Aliases)` metadata. This then causes the following error: Error CS1681: You cannot redefine the global extern alias (CS1681) Fix this by ignoring the `global` entry if one is present.
…e. (#4554) Fixes: #4542 Our previous fix in d18c824 did not take into account that users might need to add `global` to their list of aliases in the `%(ProjectReference.Aliases)` metadata. This then causes the following error: Error CS1681: You cannot redefine the global extern alias (CS1681) Fix this by ignoring the `global` entry if one is present.
Release status update A new Preview version of Xamarin.Android has now been published that includes the fix for this item. The fix is not yet included in a Release version. I will update this again when a Release version is available that includes the fix. Fix included in Xamarin.Android 10.4.0.0. Fix included on Windows in Visual Studio 2019 version 16.7 Preview 3. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview. Fix included on macOS in Visual Studio 2019 for Mac version 8.7 Preview 3. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel. |
Release status update A new Release version of Xamarin.Android has now been published that includes the fix for this item. Fix included in Xamarin.Android SDK version 11.0.0.3. Fix included on Windows in Visual Studio 2019 version 16.7. To get the new version that includes the fix, check for the latest updates or install the most recent release from https://visualstudio.microsoft.com/downloads/. Fix included on macOS in Visual Studio 2019 for Mac version 8.7. To get the new version that includes the fix, check for the latest updates on the Stable updater channel. |
Thanks everybody for working on this. I updated to this version a few days ago and everything works. |
I've attached a sample project and the diagnostic build output when building in Visual Studio 16.4.6/Xamarin.Android.10.1 and VS 16.5.3/Xamarin.Android.10.2. The problematic behavior is also seen in VS 16.5.2.
When built with 10.1 the project builds as expected. No
extern alias
lines are added to the generated resource file.When built with 10.2 the project fails to build because
extern alias
lines (in my sample there are 2) with invalid syntax from the project file are added to the generated resource file.I understand this may be connected to #3808 and #4409 and their fixes, but it seems there is still an issue with how these lines are added or that they are added at all as they seem to be unnecessary. The aliased libraries are not referenced in the resource file and the project builds fine without them in 10.1.
I modeled my sample project after the real project that has
<Aliases>
tags added for references to the same two nuget packages used in my sample project. I didn't write this code, so there may be something else going on. It might be that it is not even correct and that is the root cause of the problem, but there is definitely a difference in the way it is handled between 10.1 and 10.2 that is less than ideal.EDIT: One more thing that I should probably mention is that this behavior isn't seen when the packages are added as
<PackageReference>
tags in the project file. When they are added the "old way" with a package.config file and are added to the project file with a<Reference>
tag the issue appears.It might also be worth pointing out that I was hoping to update to 10.2 to avoid this issue: #18106 so right it seems like I am between a rock and a hard place.
xamarin.android.10.1.txt
xamarin.android.10.2.txt
App1.zip
The text was updated successfully, but these errors were encountered: