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
179 stars 34 forks source link

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

Open bitbound opened 4 days ago

bitbound commented 4 days ago

Repro Steps:

dotnet SDK Version: 8.0.400

image

image

baronfel commented 4 days 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 4 days ago

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

msbuild.zip

baronfel commented 4 days 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 4 days 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 4 days 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 4 days 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 4 days 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. 🙂