sdk-container-builds icon indicating copy to clipboard operation
sdk-container-builds copied to clipboard

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

Open bitbound opened this issue 1 year ago • 7 comments

Repro Steps:

  • In Visual Studio on Windows 11, create a new solution/project from the ASP.NET Core Web API template
  • Select the options shown in the below screenshot
  • In pwsh in the project dir, enter dotnet publish --os linux --arch x64 -c Release /p:PublishProfile=DefaultContainer
    • dotnet publish --os linux --arch x64 /t:PublishContainer produces the same result
  • Observe the error
  • Note that the ContainerPort is already specified in the error's suggested format

dotnet SDK Version: 8.0.400

image

image

bitbound avatar Sep 18 '24 15:09 bitbound

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.

baronfel avatar Sep 18 '24 15:09 baronfel

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

msbuild.zip

bitbound avatar Sep 18 '24 16:09 bitbound

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'

baronfel avatar Sep 18 '24 16:09 baronfel

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 avatar Sep 18 '24 16:09 bitbound

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.

bitbound avatar Sep 18 '24 16:09 bitbound

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

baronfel avatar Sep 18 '24 16:09 baronfel

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. 🙂

bitbound avatar Sep 18 '24 16:09 bitbound

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

maw136 avatar Oct 08 '24 09:10 maw136

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.

baronfel avatar Oct 09 '24 14:10 baronfel