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

.NET 7.0: Arm64 Docker build fails with NullReferenceException for TargetOutputs on restore step #29892

Closed
DrEsteban opened this issue Jan 11, 2023 · 15 comments
Assignees
Labels
Area-NetSDK untriaged Request triage from a team member

Comments

@DrEsteban
Copy link

DrEsteban commented Jan 11, 2023

I have a project that I'm trying to upgrade from .NET 6.0 -> .NET 7.0. I run this project as a container on a Raspberry Pi, so I run my docker builds with --platform arm64. I don't build on the Pi, but on my Windows 11 machine.

Here is a direct link to a branch in my project where I'm attempting to upgrade to .NET 7.0: https://github.com/DrEsteban/SolarGateway_PrometheusProxy/tree/net7.0

Repro steps
The following works:

  1. Checkout repository
  2. Open command prompt to repo root
  3. docker build .
  4. Produces an image as expected

The following does not work:

  1. Checkout repository
  2. Open command prompt to repo root
  3. docker build --platform arm64 .
  4. Fails at the restore step with:
> [build 4/6] RUN dotnet restore "SolarGateway_PrometheusProxy.csproj":
#10 7.132   Determining projects to restore...
#10 7.187 /usr/share/dotnet/sdk/7.0.102/NuGet.targets(1235,7): error MSB4018: The "MSBuild" task failed unexpectedly. [/src/SolarGateway_PrometheusProxy.csproj]
#10 7.187 /usr/share/dotnet/sdk/7.0.102/NuGet.targets(1235,7): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object. [/src/SolarGateway_PrometheusProxy.csproj]
#10 7.187 /usr/share/dotnet/sdk/7.0.102/NuGet.targets(1235,7): error MSB4018:    at InvokeStub_MSBuild.get_TargetOutputs(Object, Object, IntPtr*) [/src/SolarGateway_PrometheusProxy.csproj]
#10 7.187 /usr/share/dotnet/sdk/7.0.102/NuGet.targets(1235,7): error MSB4018:    at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr) [/src/SolarGateway_PrometheusProxy.csproj]
#10 7.188 /usr/share/dotnet/sdk/7.0.102/NuGet.targets(1235,7): error MSB4028: The "MSBuild" task's outputs could not be retrieved from the "TargetOutputs" parameter. Object reference not set to an instance of an object. [/src/SolarGateway_PrometheusProxy.csproj]
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Jan 11, 2023
@DrEsteban DrEsteban changed the title .NET 7.0: Arm64 Docker build fails with NullReferenceException for TargetOutputs .NET 7.0: Arm64 Docker build fails with NullReferenceException for TargetOutputs on restore step Jan 11, 2023
@marcpopMSFT marcpopMSFT self-assigned this Jan 18, 2023
@alexrosenfeld10
Copy link

I'm having the same issue.

@alexrosenfeld10
Copy link

alexrosenfeld10 commented Feb 13, 2023

seems like a duplicate of #28971 / NuGet/Home#12227?

@DrEsteban
Copy link
Author

@alexrosenfeld10 The root cause could very well be the same, but note the error messages in those 2 issues are much different than what I'm seeing. Same step in the process, but a very different error.

@DrEsteban
Copy link
Author

Also, here's an update. I just pulled the latest versions of mcr.microsoft.com/dotnet/sdk:7.0 and mcr.microsoft.com/dotnet/aspnet:7.0 and tried the build again, and the error message is slightly different now:

 > [build 4/6] RUN dotnet restore "SolarGateway_PrometheusProxy.csproj":
#11 8.090   Determining projects to restore...
#11 8.256 /usr/share/dotnet/sdk/7.0.103/NuGet.targets(1109,7): error MSB4018: The "RemoveDuplicates" task failed unexpectedly. [/src/SolarGateway_PrometheusProxy.csproj]
#11 8.256 /usr/share/dotnet/sdk/7.0.103/NuGet.targets(1109,7): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object. [/src/SolarGateway_PrometheusProxy.csproj]
#11 8.256 /usr/share/dotnet/sdk/7.0.103/NuGet.targets(1109,7): error MSB4018:    at InvokeStub_RemoveDuplicates.get_Filtered(Object, Object, IntPtr*) [/src/SolarGateway_PrometheusProxy.csproj]
#11 8.256 /usr/share/dotnet/sdk/7.0.103/NuGet.targets(1109,7): error MSB4018:    at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr) [/src/SolarGateway_PrometheusProxy.csproj]
#11 8.257 /usr/share/dotnet/sdk/7.0.103/NuGet.targets(1109,7): error MSB4028: The "RemoveDuplicates" task's outputs could not be retrieved from the "Filtered" parameter. Object reference not set to an instance of an object. [/src/SolarGateway_PrometheusProxy.csproj]

@DrEsteban
Copy link
Author

And just to clarify, this issue doesn't repro at all when I use the .NET 6 SDK & images.

@alexrosenfeld10
Copy link

yep I downgraded to net6.0 today because of similar stuff.

@marcpopMSFT
Copy link
Member

Adding @richlander who's been doing a lot of docker scenarios similar to this one to take a look.

@austinlparker
Copy link

Also seeing this intermittently when running .NET 7 builds in QEMU. Logs here: https://gist.github.com/austinlparker/b512198a748f67cf6574b684f2648c52

@Jesn
Copy link

Jesn commented Aug 24, 2023

#50 29.03 /usr/share/dotnet/sdk/7.0.400/NuGet.targets(1244,7): error MSB4018:    at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr) [**/HttpApi.Host.csproj]

#50 29.03 /usr/share/dotnet/sdk/7.0.400/NuGet.targets(1244,7): error MSB4028: The "MSBuild" task's outputs could not be retrieved from the "TargetOutputs" parameter. Object reference not set to an instance of an object. [**/Rich.MagicNetWork.HttpApi.Host.csproj]

I have also encountered similar problems. I have succeeded several times, but 99% have failed

@Jesn
Copy link

Jesn commented Aug 24, 2023

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:7.0 AS build

add --platform=$BUILDPLATFORM

image

@werwolfby
Copy link

@Jesn thanks! --platform=$BUILDPLATFORM really helped!

@DrEsteban
Copy link
Author

Hmm I tried adding the --platform flag to the Dockerfile itself as described above, but continue to see the same issues during package restore.

@DrEsteban
Copy link
Author

This article, and .NET 8.0 in general, has helped me greatly!!

https://devblogs.microsoft.com/dotnet/improving-multiplatform-container-support/

@DrEsteban
Copy link
Author

Marking as closed due to improvements in .NET 8.0 container support.

Julian added a commit to bowtie-json-schema/bowtie that referenced this issue Feb 4, 2024
@yabood
Copy link

yabood commented Mar 18, 2024

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:7.0 AS build

add --platform=$BUILDPLATFORM
image

This worked, thanks!

SdtBarbarossa added a commit to swgoh-utils/swgoh-ae2 that referenced this issue Jul 10, 2024
munelear pushed a commit to swgoh-utils/swgoh-ae2 that referenced this issue Jul 10, 2024
# [1.4.0](v1.3.0...v1.4.0) (2024-07-10)

### Bug Fixes

* add --platform as in dotnet/sdk#29892 ([3c8a582](3c8a582))
* Dockerimage build with .Net 8 (non slim) ([0221910](0221910))
* use .Net 8 for Docker ([5fde58c](5fde58c))

### Features

* Compatible with Unity 2022.3 ([d7c9dc9](d7c9dc9))
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

8 participants