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
175 stars 30 forks source link

The "ContainerFamily" parameter is not supported by the "ComputeDotnetBaseImageTag" #530

Open rido-min opened 6 months ago

rido-min commented 6 months ago

I was successfully creating containers with dotnet publish /t:PublicContainer, once my VS got updated to .NET8 SDK, the projects (still targeting .NET7) fail with.

C:\Program Files\dotnet\sdk\8.0.100\Containers\build\Microsoft.NET.Build.Containers.targets(37,7): 
error MSB4064: The "ContainerFamily" parameter is not supported by the "ComputeDotnetBaseImageTag" task loaded from assembly: 
Microsoft.NET.Build.Containers, Version=7.0.401.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 from the path: 
C:\Users\user\.nuget\packages\microsoft.net.build.containers\7.0.401\tasks\net7.0\Microsoft.NET.Build.Containers.dll. 
Verify that the parameter exists on the task, the <UsingTask> points to the correct assembly, and it is a settable public instance property. [D:\code\temp\MyModule071\MyModule071.csproj]

C:\Program Files\dotnet\sdk\8.0.100\Containers\build\Microsoft.NET.Build.Containers.targets(34,5): 
error MSB4063: The "ComputeDotnetBaseImageTag" task could not be initialized with its input parameters.  [D:\code\temp\MyModule071\MyModule071.csproj]

I noticed that removing the <PackageReference Include="Microsoft.NET.Build.Containers" Version="7.0.401" /> fixes the issue, however we have templates with the package reference, and we might need to tell our users to remove manually the ref from projects generated from the template.

baronfel commented 6 months ago

In general you should not mix using the package with using the .NET SDK. For Web and Worker projects you should use the SDK support. For console projects, you should use the Package support.

Starting in 8.0.200, even console applications will be able to use the SDK support, so the motivation for the package will be much reduced.

iAmBipinPaul commented 3 weeks ago

Hi @rido-min uninstall Microsoft.NET.Build.Containers and it should work fine