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

PrivateAssets="All" breaks Android apps #47332

Open
Kira-NT opened this issue Mar 6, 2025 · 1 comment
Open

PrivateAssets="All" breaks Android apps #47332

Kira-NT opened this issue Mar 6, 2025 · 1 comment
Assignees
Labels
Area-NetSDK untriaged Request triage from a team member

Comments

@Kira-NT
Copy link

Kira-NT commented Mar 6, 2025

Description

Hi! I'm developing a hot reload plugin for a UI framework. Well, technically, it's already done, and now I'm faced with the real challenge - packaging it.

Naturally, since my package is designed as a development-only dependency, I pack it with -p:DevelopmentDependency=true. Thus, when users install it, the following snippet is added to their project file:

<PackageReference Include="Foo" Version="...">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>

which is equivalent to:

<PackageReference Include="Foo" Version="..." PrivateAssets="All" />

And everything behaves properly whenever the plugin is used with a desktop application, whether it's created via dotnet build or dotnet run.

However, the moment I try to run an Android app via dotnet run, it instantly crashes with a cryptic FileNotFoundException, signifying that the satellite library required for debug builds to function has not been included in the resulting bundle. As far as I understand after four days of digging through the best documentation I have on this topic (i.e., the sources of this repo and eight-year-old issues), this happens because dotnet run for Android builds actually uses the publish routine to generate the output that gets uploaded to the device; and the SDK by default sets Publish="false" for every PackageReference that has its PrivateAssets set to all, causing development-only dependencies to go missing, even though the intent was not to publish the app, but to create a development build for debugging purposes.

Workarounds

The ugly workaround would be to ask users to install the plugin by manually editing their project files and inserting the following snippet there:

<PackageReference Include="Foo" Version="..." PrivateAssets="All" Publish="True" />

It's "ugly" because:

  1. Nobody reads documentation these days, so this will just lead to an endless stream of "No work! Crash! How fix?" issues in my repo.
  2. This doesn't actually represent the proper intent of what I'm trying to achieve. I do not want my satellite library to be copied to users' published builds. It's only needed for regular debug builds, which I expect Android builds created by dotnet run to be. However, those unexpectedly differ in semantics from the desktop ones.

Sooooo... Are there any somewhat proper workarounds I can employ within the .props/.targets distributed with my nuget, so that users can simply run dotnet add package Foo and expect everything to work as intended?

Related Issues

#27211
#1019
#952

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Mar 6, 2025
@Forgind
Copy link
Member

Forgind commented Mar 11, 2025

I'm not sure if this is a bug in the SDK, the android workload, or something else. Would it be possible to provide a binlog? And perhaps adb logcat?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-NetSDK untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

2 participants