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

dotnet new android attempts to restore Microsoft.AspNetCore.App.Runtime.linux-arm64 #19891

Closed
jonathanpeppers opened this issue Aug 19, 2021 · 12 comments
Assignees
Milestone

Comments

@jonathanpeppers
Copy link
Member

jonathanpeppers commented Aug 19, 2021

If you install .NET 6 RC1 and the Android workload, we are now using **FromWorkload** so a NuGet.config should no longer be needed when building Android projects.

Unfortunately, you get a different error now when testing this:

error NU1102: Unable to find package Microsoft.AspNetCore.App.Runtime.linux-arm64 with version (= 6.0.0-rc.1.21417.2)

Build log: msbuild.zip

I found I could workaround the problem with:

<Target Name="_RemoveLinuxFrameworkReferences"
    AfterTargets="ProcessFrameworkReferences">
  <ItemGroup>
    <_ProblematicRIDs Include="linux-arm;linux-arm64;linux-x86;linux-x64" />
    <PackageDownload Remove="Microsoft.AspNetCore.App.Runtime.%(_ProblematicRIDs.Identity)" />
    <PackageDownload Remove="Microsoft.NETCore.App.Host.%(_ProblematicRIDs.Identity)" />
  </ItemGroup>
</Target>

I will probably put this workaround in the Android workload for now.

This is probably related to the RID graph. I tried making an adjustment to the RID graph in the past, but they wouldn't accept this change:

dotnet/runtime#45927

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-External untriaged Request triage from a team member labels Aug 19, 2021
@jonathanpeppers
Copy link
Member Author

/cc @dsplaisted @wli3

jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Aug 19, 2021
Context: dotnet/sdk#19891

If you `dotnet new android` and `dotnet build` it without a
`NuGet.config` you hit:

    error NU1102: Unable to find package Microsoft.AspNetCore.App.Runtime.linux-arm64 with version (= 6.0.0-rc.1.21417.2)

I found I could workaround the problem by removing `linux-*` packages
at a certain point during the build:

    <Target Name="_RemoveLinuxFrameworkReferences"
        AfterTargets="ProcessFrameworkReferences">
      <ItemGroup>
        <_ProblematicRIDs Include="linux-arm;linux-arm64;linux-x86;linux-x64" />
        <PackageDownload Remove="Microsoft.AspNetCore.App.Runtime.%(_ProblematicRIDs.Identity)" />
        <PackageDownload Remove="Microsoft.NETCore.App.Host.%(_ProblematicRIDs.Identity)" />
      </ItemGroup>
    </Target>

With this target in place, I can build projects without a
`NuGet.config` file. Let's put this workaround in place until we have
another solution for dotnet/sdk#19891.

To validate these changes, I removed any instances of the `dotnet6`
feed in our MSBuild tests.
jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Aug 19, 2021
Context: dotnet/sdk#19891

If you `dotnet new android` and `dotnet build` it without a
`NuGet.config` you hit:

    error NU1102: Unable to find package Microsoft.AspNetCore.App.Runtime.linux-arm64 with version (= 6.0.0-rc.1.21417.2)

I found I could workaround the problem by removing `linux-*` packages
at a certain point during the build:

    <Target Name="_RemoveLinuxFrameworkReferences"
        AfterTargets="ProcessFrameworkReferences">
      <ItemGroup>
        <_ProblematicRIDs Include="linux-arm;linux-arm64;linux-x86;linux-x64" />
        <PackageDownload Remove="Microsoft.AspNetCore.App.Runtime.%(_ProblematicRIDs.Identity)" />
        <PackageDownload Remove="Microsoft.NETCore.App.Host.%(_ProblematicRIDs.Identity)" />
      </ItemGroup>
    </Target>

With this target in place, I can build projects without a
`NuGet.config` file. Let's put this workaround in place until we have
another solution for dotnet/sdk#19891.

To validate these changes, I removed any instances of the `dotnet6`
feed in our MSBuild tests.
@jonathanpeppers
Copy link
Member Author

Oh, this did come up before: #11289

jonathanpeppers added a commit to dotnet/android that referenced this issue Aug 20, 2021
…6207)

Context: dotnet/sdk#19891

If you `dotnet new android` and `dotnet build` it without a
`NuGet.config` you hit:

    error NU1102: Unable to find package Microsoft.AspNetCore.App.Runtime.linux-arm64 with version (= 6.0.0-rc.1.21417.2)

I found I could workaround the problem by removing `linux-*` packages
at a certain point during the build:

    <Target Name="_RemoveLinuxFrameworkReferences"
        AfterTargets="ProcessFrameworkReferences">
      <ItemGroup>
        <_ProblematicRIDs Include="linux-arm;linux-arm64;linux-x86;linux-x64" />
        <PackageDownload Remove="Microsoft.AspNetCore.App.Runtime.%(_ProblematicRIDs.Identity)" />
        <PackageDownload Remove="Microsoft.NETCore.App.Host.%(_ProblematicRIDs.Identity)" />
      </ItemGroup>
    </Target>

With this target in place, I can build projects without a
`NuGet.config` file. Let's put this workaround in place until we have
another solution for dotnet/sdk#19891.

To validate these changes, I removed any instances of the `dotnet6`
feed in our MSBuild tests.
jonathanpeppers added a commit to dotnet/android that referenced this issue Aug 20, 2021
…6207)

Context: dotnet/sdk#19891

If you `dotnet new android` and `dotnet build` it without a
`NuGet.config` you hit:

    error NU1102: Unable to find package Microsoft.AspNetCore.App.Runtime.linux-arm64 with version (= 6.0.0-rc.1.21417.2)

I found I could workaround the problem by removing `linux-*` packages
at a certain point during the build:

    <Target Name="_RemoveLinuxFrameworkReferences"
        AfterTargets="ProcessFrameworkReferences">
      <ItemGroup>
        <_ProblematicRIDs Include="linux-arm;linux-arm64;linux-x86;linux-x64" />
        <PackageDownload Remove="Microsoft.AspNetCore.App.Runtime.%(_ProblematicRIDs.Identity)" />
        <PackageDownload Remove="Microsoft.NETCore.App.Host.%(_ProblematicRIDs.Identity)" />
      </ItemGroup>
    </Target>

With this target in place, I can build projects without a
`NuGet.config` file. Let's put this workaround in place until we have
another solution for dotnet/sdk#19891.

To validate these changes, I removed any instances of the `dotnet6`
feed in our MSBuild tests.
@sfoslund sfoslund added needs team triage Requires a full team discussion and removed untriaged Request triage from a team member labels Aug 25, 2021
@sfoslund sfoslund removed their assignment Aug 25, 2021
@marcpopMSFT marcpopMSFT added untriaged Request triage from a team member and removed needs team triage Requires a full team discussion labels Aug 25, 2021
@marcpopMSFT marcpopMSFT added this to the 6.0.1xx milestone Aug 25, 2021
@marcpopMSFT
Copy link
Member

@jonathanpeppers is this still an issue we should be investigating?

@marcpopMSFT marcpopMSFT modified the milestones: 6.0.1xx, 6.0.2xx Oct 6, 2021
@jonathanpeppers
Copy link
Member Author

@marcpopMSFT yes we still have this workaround in place:

dotnet/android@d8fca1c

This at least prevents various Linux files from being added to Android apps.

I don't remember if the Linux packages are still being restored or not.

@marcpopMSFT marcpopMSFT added needs team triage Requires a full team discussion and removed needs team triage Requires a full team discussion labels Oct 13, 2021
@jonathanpeppers
Copy link
Member Author

jonathanpeppers commented Oct 19, 2021

It appears we still attempt to restore these packages:

C:\src\foo\foo.csproj : error NU1102: Unable to find package Microsoft.AspNetCore.App.Runtime.linux-arm with version (= 6.0.0-rtm.21475.9)
C:\src\foo\foo.csproj : error NU1102:   - Found 65 version(s) in nuget.org [ Nearest version: 6.0.0-rc.2.21480.10 ]
C:\src\foo\foo.csproj : error NU1102:   - Found 0 version(s) in Microsoft Visual Studio Offline Packages
C:\src\foo\foo.csproj : error NU1102: Unable to find package Microsoft.AspNetCore.App.Runtime.linux-arm64 with version (= 6.0.0-rtm.21475.9)
C:\src\foo\foo.csproj : error NU1102:   - Found 65 version(s) in nuget.org [ Nearest version: 6.0.0-rc.2.21480.10 ]
C:\src\foo\foo.csproj : error NU1102:   - Found 0 version(s) in Microsoft Visual Studio Offline Packages
C:\src\foo\foo.csproj : error NU1102: Unable to find package Microsoft.AspNetCore.App.Runtime.linux-x64 with version (= 6.0.0-rtm.21475.9)
C:\src\foo\foo.csproj : error NU1102:   - Found 65 version(s) in nuget.org [ Nearest version: 6.0.0-rc.2.21480.10 ]
C:\src\foo\foo.csproj : error NU1102:   - Found 0 version(s) in Microsoft Visual Studio Offline Packages
C:\src\foo\foo.csproj : error NU1102: Unable to find package Microsoft.NETCore.App.Host.linux-arm with version (= 6.0.0-rtm.21472.13)
C:\src\foo\foo.csproj : error NU1102:   - Found 65 version(s) in nuget.org [ Nearest version: 6.0.0-rc.2.21480.5 ]
C:\src\foo\foo.csproj : error NU1102:   - Found 0 version(s) in Microsoft Visual Studio Offline Packages
C:\src\foo\foo.csproj : error NU1102: Unable to find package Microsoft.NETCore.App.Host.linux-arm64 with version (= 6.0.0-rtm.21472.13)
C:\src\foo\foo.csproj : error NU1102:   - Found 65 version(s) in nuget.org [ Nearest version: 6.0.0-rc.2.21480.5 ]
C:\src\foo\foo.csproj : error NU1102:   - Found 0 version(s) in Microsoft Visual Studio Offline Packages
C:\src\foo\foo.csproj : error NU1102: Unable to find package Microsoft.NETCore.App.Host.linux-x64 with version (= 6.0.0-rtm.21472.13)
C:\src\foo\foo.csproj : error NU1102:   - Found 65 version(s) in nuget.org [ Nearest version: 6.0.0-rc.2.21480.5 ]
C:\src\foo\foo.csproj : error NU1102:   - Found 0 version(s) in Microsoft Visual Studio Offline Packages
    0 Warning(s)
    6 Error(s)

Should I do something to work around this? I could probably remove these from some item group in the Android workload.

@dsplaisted dsplaisted removed Area-External untriaged Request triage from a team member labels Oct 21, 2021
@dsplaisted
Copy link
Member

We discussed this and think that the Android SDK should probably be able to set UseAppHost to false to fix the apphost issues. For the runtime packs, we probably want to add a feature that allows the ASP.NET KnownFrameworkReference item to specify RuntimePackExcludedRuntimeIdentifiers="android" to prevent it from trying to acquire the runtime pack for Android.

@jonathanpeppers
Copy link
Member Author

@dsplaisted it still seems to bring in packs when UseAppHost=false:

msbuild.zip

If you see what we need to do let me know, my changes are on a branch here:

dotnet/android@main...jonathanpeppers:useapphost-false

@akoeplinger
Copy link
Member

@jonathanpeppers
Copy link
Member Author

I missed $(_RuntimeIdentifierUsesAppHost), will try that.

jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Oct 22, 2021
Context: dotnet/sdk#19891
Context: https://github.com/xamarin/xamarin-macios/blob/a6eb528197854c074d9dd5847328c096890337be/dotnet/targets/Xamarin.Shared.Sdk.props#L38-L52

We currently have a small hack in place to prevent Linux packages from
being used in .NET 6 builds:

    <!-- HACK: workaround for: dotnet/sdk#19891 -->
    <Target Name="_RemoveLinuxFrameworkReferences"
        AfterTargets="ProcessFrameworkReferences">
      <ItemGroup>
        <_ProblematicRIDs Include="linux-arm;linux-arm64;linux-x86;linux-x64" />
        <PackageDownload Remove="Microsoft.AspNetCore.App.Runtime.%(_ProblematicRIDs.Identity)" />
        <PackageDownload Remove="Microsoft.NETCore.App.Host.%(_ProblematicRIDs.Identity)" />
      </ItemGroup>
    </Target>

The Xamarin.iOS team found if you set this late during
`$(AfterMicrosoftNETSdkTargets)`:

    <_RuntimeIdentifierUsesAppHost>false</_RuntimeIdentifierUsesAppHost>
    <UseAppHost>false</UseAppHost>

Then `Microsoft.NETCore.App.Host.*` packs won't be brought in.

After making this change, I can remove this line from the workaround:

    <PackageDownload Remove="Microsoft.NETCore.App.Host.%(_ProblematicRIDs.Identity)" />

The final solution for dotnet/sdk#19891, will be a future change that
makes `Microsoft.AspNetCore.App.Runtime` have a way to ignore
unsupported platforms.
@jonathanpeppers
Copy link
Member Author

Ok great this gets us closer: dotnet/android#6417

So only the Microsoft.AspNetCore.App.Runtime.linux-* packs are left now.

jonathanpeppers added a commit to dotnet/android that referenced this issue Oct 25, 2021
Context: dotnet/sdk#19891
Context: https://github.com/xamarin/xamarin-macios/blob/a6eb528197854c074d9dd5847328c096890337be/dotnet/targets/Xamarin.Shared.Sdk.props#L38-L52

We currently have a small hack in place to prevent Linux packages from
being used in .NET 6 builds:

    <!-- HACK: workaround for: dotnet/sdk#19891 -->
    <Target Name="_RemoveLinuxFrameworkReferences"
        AfterTargets="ProcessFrameworkReferences">
      <ItemGroup>
        <_ProblematicRIDs Include="linux-arm;linux-arm64;linux-x86;linux-x64" />
        <PackageDownload Remove="Microsoft.AspNetCore.App.Runtime.%(_ProblematicRIDs.Identity)" />
        <PackageDownload Remove="Microsoft.NETCore.App.Host.%(_ProblematicRIDs.Identity)" />
      </ItemGroup>
    </Target>

The Xamarin.iOS team found if you set this late during
`$(AfterMicrosoftNETSdkTargets)`:

    <_RuntimeIdentifierUsesAppHost>false</_RuntimeIdentifierUsesAppHost>
    <UseAppHost>false</UseAppHost>

Then `Microsoft.NETCore.App.Host.*` packs won't be brought in.

After making this change, I can remove this line from the workaround:

    <PackageDownload Remove="Microsoft.NETCore.App.Host.%(_ProblematicRIDs.Identity)" />

The final solution for dotnet/sdk#19891, will be a future change that
makes `Microsoft.AspNetCore.App.Runtime` have a way to ignore
unsupported platforms.
@marcpopMSFT marcpopMSFT modified the milestones: 6.0.2xx, 6.0.3xx Dec 11, 2021
@marcpopMSFT
Copy link
Member

@jonathanpeppers closing to be tracked by newer discussions we have going on. If this is still a separate issue, feel free to reactivate.

@jonathanpeppers
Copy link
Member Author

I think this is fixed, but I'll try removing this target to be sure:

https://github.com/xamarin/xamarin-android/blob/5efda9d6923bb2478a2efb2e17104791a169ec1f/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AssemblyResolution.targets#L17-L24

jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Mar 24, 2022
….linux workaround

Context: dotnet/sdk#19891

In 3f052b5, I added a workaround to exclude
`Microsoft.AspNetCore.App.Runtime.linux` packages from Android builds.
This was a problem where the `android` RID "inherited" from the
`linux` RID, and so we ended up with unintended packages restored.

This was fixed in dotnet/installer#12702, so
we should remove this workaround.
dellis1972 pushed a commit to dotnet/android that referenced this issue Mar 24, 2022
….linux workaround (#6851)

Context: dotnet/sdk#19891

In 3f052b5, I added a workaround to exclude
`Microsoft.AspNetCore.App.Runtime.linux` packages from Android builds.
This was a problem where the `android` RID "inherited" from the
`linux` RID, and so we ended up with unintended packages restored.

This was fixed in dotnet/installer#12702, so
we should remove this workaround.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants