dotnet / sdk-container-builds

Libraries and build tooling to create container images from .NET projects using MSBuild
https://learn.microsoft.com/en-us/dotnet/core/docker/publish-as-container
MIT License
181 stars 39 forks source link

Error when publishing web app template: error CONTAINER2016 : ContainerPort item '8081' does not specify the port number. #596

Closed bitbound closed 1 month ago

bitbound commented 2 months ago

Repro Steps:

dotnet SDK Version: 8.0.400

image

image

baronfel commented 2 months ago

Thanks for the report! Can you get an binlog (add the /bl flag) to dig in a bit more? I'm really interested in what is passed to the CreateNewImage Task as the value of the ExposedPorts parameter.

bitbound commented 2 months ago

@baronfel Thanks for the quick reply. Here you go!

msbuild.zip

baronfel commented 2 months ago

Ok, this is a bug in both our parsing and our error reporting. If you set the Type="tcp" metadata on the ContainerPort then things should work.

What's happening is that

bitbound commented 2 months ago

Ok, this is a bug in both our parsing and our error reporting. If you set the Type="tcp" metadata on the ContainerPort then things should work.

What's happening is that

  • we're using a string is null check instead of a string is null or empty check in a key location
  • and we're incorrectly unpacking an error enum that contains detailed error information in a way that makes the error look like a missing port when the real error is 'missing type'

That worked. 🙂 Thank you very much!

bitbound commented 2 months ago

Perhaps I spoke too soon. It's working for the API template project. For my actual project at work, I'm getting:

image

The end goal is to get azd up to deploy an Aspire app to Azure, within in which this project is a service. I'm seeing the above error with both dotnet publish ... and azd up.

baronfel commented 2 months ago

this error is a bug in .NET 8.0.400 and .NET 9 preview 7 that you should be able to resolve by updating to 8.0.401 and/or .NET 9.0.100-rc.1

bitbound commented 2 months ago

this error is a bug in .NET 8.0.400 and .NET 9 preview 7 that you should be able to resolve by updating to 8.0.401 and/or .NET 9.0.100-rc.1

Awesome. Thanks for your time, friend. 🙂

maw136 commented 1 month ago

Hello, unfortunately even with 8.0.402 SDK the issue exists and kicks one in the butt :(

baronfel commented 1 month ago

That's to be expected - we just merged the linked PR for .NET 9 GA a few days ago, and .NET 8.0.400 at the same time. I'd expect this fix to land in the November releases of both SDKs as a result.