Error when publishing web app template: error CONTAINER2016 : ContainerPort item '8081' does not specify the port number.
Repro Steps:
- In Visual Studio on Windows 11, create a new solution/project from the
ASP.NET Core Web APItemplate - 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:PublishContainerproduces 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
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.
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'
Ok, this is a bug in both our parsing and our error reporting. If you set the
Type="tcp"metadata on theContainerPortthen 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!
Perhaps I spoke too soon. It's working for the API template project. For my actual project at work, I'm getting:
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.
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
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. 🙂
Hello, unfortunately even with 8.0.402 SDK the issue exists and kicks one in the butt :(
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.