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

CS1504 with AndroidBoundLayout when building with .NET 8 SDK #8516

Open
rgroenewoudt opened this issue Nov 17, 2023 · 9 comments
Open

CS1504 with AndroidBoundLayout when building with .NET 8 SDK #8516

rgroenewoudt opened this issue Nov 17, 2023 · 9 comments
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects.

Comments

@rgroenewoudt
Copy link

Android application type

.NET Android (net7.0-android, etc.)

Affected platform version

VS 2022 17.8

Description

After upgrading to VS2022 17.8, I cannot build my .NET 7 Android app anymore. Same issue with dotnet build.

For every Android layout file with build action 'AndroidBoundLayout', I'm getting the build error:

project\obj\Debug\net7.0-android33.0\generated\Binding.About.g.cs(27,11): error CS1504: Source file 'Resources\Layout\About.xml' could not be opened -- Could not find file.

The generated .cs file contains code #line 2 "Resources\Layout\About.xml" which seems to break compiling.

Steps to Reproduce

Use .NET 8 SDK to build a project with AndroidBoundLayout file.

Did you find any workaround?

No response

Relevant log output

No response

@rgroenewoudt rgroenewoudt added Area: App+Library Build Issues when building Library projects or Application projects. needs-triage Issues that need to be assigned. labels Nov 17, 2023
@dellis1972
Copy link
Contributor

@rgroenewoudt have you tried deleting the bin and obj directories and completely rebuilding?

@dellis1972 dellis1972 added need-info Issues that need more information from the author. and removed needs-triage Issues that need to be assigned. labels Nov 17, 2023
@rgroenewoudt
Copy link
Author

@dellis1972 Of course, no difference.

@microsoft-github-policy-service microsoft-github-policy-service bot added need-attention A xamarin-android contributor needs to review and removed need-info Issues that need more information from the author. labels Nov 17, 2023
@rgroenewoudt
Copy link
Author

This might be related to dotnet/sdk#34438

@dellis1972
Copy link
Contributor

Yup, I think there was a change in the SDK which caused this.
A fix for LayoutBindings went into .net 8 via 2b0761b. But afaik it was not back ported to .net 7.

@rgroenewoudt
Copy link
Author

Are there tests missing for building a project with AndroidBoundLayout?

@dellis1972
Copy link
Contributor

@rgroenewoudt not on the .net android side, we have a number of tests which check that this works. Thats how we found the fix which went into 2b0761b

@rgroenewoudt
Copy link
Author

The workaround <EmbedUntrackedSources>false</EmbedUntrackedSources> works.

It might be worth it to have a test for building the previous version with the latest SDK.

@dellis1972
Copy link
Contributor

@jonpryor this is the #line issue we spoke about. Apparently disabling EmbedUntrackedSources MSBuild property fixes the issue...

@dellis1972
Copy link
Contributor

@jpobst jpobst removed the need-attention A xamarin-android contributor needs to review label Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: App+Library Build Issues when building Library projects or Application projects.
Projects
None yet
Development

No branches or pull requests

4 participants